OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // If directory files changes too often, don't rescan directory more than once | 5 // If directory files changes too often, don't rescan directory more than once |
6 // per specified interval | 6 // per specified interval |
7 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; | 7 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; |
8 // Used for operations that require almost instant rescan. | 8 // Used for operations that require almost instant rescan. |
9 var SHORT_RESCAN_INTERVAL = 100; | 9 var SHORT_RESCAN_INTERVAL = 100; |
10 | 10 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 dirContents.replaceContextFileList(); | 489 dirContents.replaceContextFileList(); |
490 | 490 |
491 this.setSelectedPaths_(selectedPaths); | 491 this.setSelectedPaths_(selectedPaths); |
492 this.fileListSelection_.leadIndex = leadIndex; | 492 this.fileListSelection_.leadIndex = leadIndex; |
493 this.setLeadPath_(leadPath); | 493 this.setLeadPath_(leadPath); |
494 this.fileListSelection_.endChange(); | 494 this.fileListSelection_.endChange(); |
495 cr.dispatchSimpleEvent(this, 'end-update-files'); | 495 cr.dispatchSimpleEvent(this, 'end-update-files'); |
496 }; | 496 }; |
497 | 497 |
498 /** | 498 /** |
499 * Delete the list of files and directories from filesystem and | |
500 * update the file list. | |
501 * @param {Array.<Entry>} entries Entries to delete. | |
502 * @param {function()=} opt_callback Called when finished. | |
503 */ | |
504 DirectoryModel.prototype.deleteEntries = function(entries, opt_callback) { | |
505 var downcount = entries.length + 1; | |
506 var currentDirPath = this.getCurrentDirPath(); | |
507 | |
508 var onComplete = opt_callback ? function() { | |
509 if (--downcount == 0) | |
510 opt_callback(); | |
511 } : function() {}; | |
512 | |
513 var fileList = this.getFileList(); | |
514 for (var i = 0; i < entries.length; i++) { | |
515 var entry = entries[i]; | |
516 | |
517 var onSuccess = function(removedEntry) { | |
518 if (currentDirPath == this.getCurrentDirPath()) { | |
519 var index = fileList.indexOf(removedEntry); | |
520 if (index >= 0) | |
521 fileList.splice(index, 1); | |
522 } | |
523 onComplete(); | |
524 }.bind(this, entry); | |
525 | |
526 util.removeFileOrDirectory( | |
527 entry, | |
528 onSuccess, | |
529 util.flog('Error deleting ' + entry.fullPath, onComplete)); | |
530 } | |
531 onComplete(); | |
532 }; | |
533 | |
534 /** | |
535 * @param {string} name Filename. | 499 * @param {string} name Filename. |
536 */ | 500 */ |
537 DirectoryModel.prototype.onEntryChanged = function(name) { | 501 DirectoryModel.prototype.onEntryChanged = function(name) { |
538 var currentEntry = this.getCurrentDirEntry(); | 502 var currentEntry = this.getCurrentDirEntry(); |
539 var fileList = this.getFileList(); | 503 var fileList = this.getFileList(); |
540 var self = this; | 504 var self = this; |
541 | 505 |
542 function onEntryFound(entry) { | 506 function onEntryFound(entry) { |
543 // Do nothing if current directory changed during async operations. | 507 // Do nothing if current directory changed during async operations. |
544 if (self.getCurrentDirEntry() != currentEntry) | 508 if (self.getCurrentDirEntry() != currentEntry) |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 }.bind(this)); | 1317 }.bind(this)); |
1354 } | 1318 } |
1355 }; | 1319 }; |
1356 | 1320 |
1357 /** | 1321 /** |
1358 * @return {DirectoryEntry} Current watched directory entry. | 1322 * @return {DirectoryEntry} Current watched directory entry. |
1359 */ | 1323 */ |
1360 FileWatcher.prototype.getWatchedDirectoryEntry = function() { | 1324 FileWatcher.prototype.getWatchedDirectoryEntry = function() { |
1361 return this.watchedDirectoryEntry_; | 1325 return this.watchedDirectoryEntry_; |
1362 }; | 1326 }; |
OLD | NEW |