(path)
| 291 | } |
| 292 | |
| 293 | var getDirChanges = function(path) { |
| 294 | var localEntries, boxEntries, currentEntryInfos, fp; |
| 295 | if (isIgnoredFile(path)) { |
| 296 | return Q(); |
| 297 | } |
| 298 | |
| 299 | logger.log("get changes in:", path); |
| 300 | |
| 301 | // File in the workspace |
| 302 | fp = new File(); |
| 303 | |
| 304 | return openFile(path).then(function(infos) { |
| 305 | return listDir(path); |
| 306 | }).then(function(entries) { |
| 307 | // Entry in the browser |
| 308 | localEntries = entries; |
| 309 | |
| 310 | // Get file on the workspace |
| 311 | return fp.getByPath(path).fail(function() { |
| 312 | return Q(); |
| 313 | }); |
| 314 | }).then(function() { |
| 315 | if (fp.isDirectory()) { |
| 316 | return fp.listdir(); |
| 317 | } |
| 318 | return Q([]); |
| 319 | }).then(function(entries) { |
| 320 | // Entries on the boxes |
| 321 | boxEntries = entries; |
| 322 | }).then(function() { |
| 323 | // Eliminate old useless entries |
| 324 | return Q.all(_.map(boxEntries, function(boxFile) { |
| 325 | if (isIgnoredFile(boxFile.path())) return Q(); |
| 326 | |
| 327 | var localEntry = _.find(localEntries, function(localEntry) { |
| 328 | return localEntry.name == boxFile.get("name"); |
| 329 | }); |
| 330 | |
| 331 | // File don't exists and box file older than current directory |
| 332 | if (!localEntry && boxFile.get("mtime") < currentEntryInfos.mtime) { |
| 333 | // -> Remove the file on the box |
| 334 | addChange(boxFile.path(), "remove"); |
| 335 | } |
| 336 | |
| 337 | // Do nothing |
| 338 | return Q(); |
| 339 | })); |
| 340 | }).then(function() { |
| 341 | // Update entries and create new entries |
| 342 | return Q.all(_.map(localEntries, function(localEntry) { |
| 343 | var entryIsDir = localEntry.mime == MIME_DIRECTORY; |
| 344 | var boxFile = _.find(boxEntries, function(boxFile) { |
| 345 | return localEntry.name == boxFile.get("name"); |
| 346 | }); |
| 347 | |
| 348 | if (!boxFile) { |
| 349 | // Create file |
| 350 | if (!entryIsDir) { |
no test coverage detected