Commit 416b5284 authored by yawano's avatar yawano Committed by Commit bot

Fixed a bug that the list still shows deleted directory.

BUG=421407
TEST=Open Files.app (WindowA); Create a directory; Open a new window of Files.app, and open the directory which is created in the previous step; Delete the directory in WindowA.

Review URL: https://codereview.chromium.org/639273002

Cr-Commit-Position: refs/heads/master@{#299076}
parent e6f0e2b1
......@@ -173,6 +173,18 @@ DirectoryModel.prototype.updateSelectionAndPublishEvent_ =
DirectoryModel.prototype.onWatcherDirectoryChanged_ = function(event) {
var directoryEntry = this.getCurrentDirEntry();
// If the change is deletion of currentDir, move up to its parent directory.
directoryEntry.getDirectory(directoryEntry.fullPath, {create: false},
null,
function() {
var volumeInfo = this.volumeManager_.getVolumeInfo(directoryEntry);
if (volumeInfo) {
volumeInfo.resolveDisplayRoot().then(function(displayRoot) {
this.changeDirectoryEntry(displayRoot);
}.bind(this));
}
}.bind(this));
if (event.changedFiles) {
var addedOrUpdatedFileUrls = [];
var deletedFileUrls = [];
......
......@@ -47,11 +47,30 @@ FileWatcher.prototype.dispose = function() {
* @private
*/
FileWatcher.prototype.onDirectoryChanged_ = function(event) {
if (this.watchedDirectoryEntry_ &&
event.entry.toURL() === this.watchedDirectoryEntry_.toURL()) {
var fireWatcherDirectoryChanged = function(changedFiles) {
var e = new Event('watcher-directory-changed');
e.changedFiles = event.changedFiles;
if (changedFiles)
e.changedFiles = changedFiles;
this.dispatchEvent(e);
}.bind(this);
if (this.watchedDirectoryEntry_) {
var eventURL = event.entry.toURL();
var watchedDirURL = this.watchedDirectoryEntry_.toURL();
if (eventURL === watchedDirURL) {
fireWatcherDirectoryChanged(event.changedFiles);
} else if (watchedDirURL.match(new RegExp('^' + eventURL))) {
// When watched directory is deleted by the change in parent directory,
// notify it as watcher directory changed.
this.watchedDirectoryEntry_.getDirectory(
this.watchedDirectoryEntry_.fullPath,
{create: false},
null,
function() { fireWatcherDirectoryChanged(null); });
}
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment