Lines 174-180
Link Here
|
174 |
@Override |
174 |
@Override |
175 |
protected void postDeleteChild(FileObject child) { |
175 |
protected void postDeleteChild(FileObject child) { |
176 |
try { |
176 |
try { |
177 |
DirectoryStorage ds = refreshDirectoryStorage(); // it will fire events itself |
177 |
DirectoryStorage ds = refreshDirectoryStorage(null); // it will fire events itself |
178 |
} catch (ConnectException ex) { |
178 |
} catch (ConnectException ex) { |
179 |
RemoteLogger.getInstance().log(Level.INFO, "Error post removing child " + child, ex); |
179 |
RemoteLogger.getInstance().log(Level.INFO, "Error post removing child " + child, ex); |
180 |
} catch (IOException ex) { |
180 |
} catch (IOException ex) { |
Lines 212-227
Link Here
|
212 |
} |
212 |
} |
213 |
if (res.isOK()) { |
213 |
if (res.isOK()) { |
214 |
try { |
214 |
try { |
215 |
refreshImpl(); |
215 |
refreshImpl(name); |
216 |
FileObject fo = getFileObject(name); |
216 |
RemoteFileObjectBase fo = getFileObject(name); |
217 |
if (fo == null) { |
217 |
if (fo == null) { |
218 |
throw new FileNotFoundException("Can not create FileObject " + getUrlToReport(path)); //NOI18N |
218 |
throw new FileNotFoundException("Can not create FileObject " + getUrlToReport(path)); //NOI18N |
219 |
} |
219 |
} |
220 |
if (directory) { |
|
|
221 |
fireFileFolderCreatedEvent(getListeners(), new FileEvent(fo)); |
222 |
} else { |
223 |
fireFileDataCreatedEvent(getListeners(), new FileEvent(fo)); |
224 |
} |
225 |
return fo; |
220 |
return fo; |
226 |
} catch (ConnectException ex) { |
221 |
} catch (ConnectException ex) { |
227 |
throw new IOException("Can not create " + path + ": not connected", ex); // NOI18N |
222 |
throw new IOException("Can not create " + path + ": not connected", ex); // NOI18N |
Lines 308-315
Link Here
|
308 |
} |
303 |
} |
309 |
} |
304 |
} |
310 |
|
305 |
|
311 |
private void fireRemoteFileObjectCreated(RemoteFileObjectBase fo) { |
306 |
private void fireRemoteFileObjectCreated(RemoteFileObjectBase fo, boolean expected) { |
312 |
FileEvent e = new FileEvent(fo); |
307 |
RemoteLogger.assertTrue(fo.getParent() == this, "Wrong parent for " + fo + ": " + fo.getParent() + " expected " + this); //NOI18N |
|
|
308 |
FileEvent e = new FileEvent(this, fo); |
313 |
if (fo instanceof RemoteDirectory) { // fo.isFolder() very slow if it is a link |
309 |
if (fo instanceof RemoteDirectory) { // fo.isFolder() very slow if it is a link |
314 |
fireFileFolderCreatedEvent(getListeners(), e); |
310 |
fireFileFolderCreatedEvent(getListeners(), e); |
315 |
} else if (fo instanceof RemotePlainFile) { |
311 |
} else if (fo instanceof RemotePlainFile) { |
Lines 392-398
Link Here
|
392 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
388 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
393 |
long time = System.currentTimeMillis(); |
389 |
long time = System.currentTimeMillis(); |
394 |
try { |
390 |
try { |
395 |
return getDirectoryStorageImpl(false); |
391 |
return getDirectoryStorageImpl(false, null); |
396 |
} finally { |
392 |
} finally { |
397 |
if (trace) { |
393 |
if (trace) { |
398 |
trace("getDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
394 |
trace("getDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
Lines 400-410
Link Here
|
400 |
} |
396 |
} |
401 |
} |
397 |
} |
402 |
|
398 |
|
403 |
private DirectoryStorage refreshDirectoryStorage() throws |
399 |
private DirectoryStorage refreshDirectoryStorage(String expectedName) throws |
404 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
400 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
405 |
long time = System.currentTimeMillis(); |
401 |
long time = System.currentTimeMillis(); |
406 |
try { |
402 |
try { |
407 |
return getDirectoryStorageImpl(true); |
403 |
return getDirectoryStorageImpl(true, expectedName); |
408 |
} finally { |
404 |
} finally { |
409 |
if (trace) { |
405 |
if (trace) { |
410 |
trace("refreshDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
406 |
trace("refreshDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
Lines 412-418
Link Here
|
412 |
} |
408 |
} |
413 |
} |
409 |
} |
414 |
|
410 |
|
415 |
private DirectoryStorage getDirectoryStorageImpl(boolean force) throws |
411 |
private DirectoryStorage getDirectoryStorageImpl(boolean force, String expectedName) throws |
416 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
412 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
417 |
|
413 |
|
418 |
if (force && ! ConnectionManager.getInstance().isConnectedTo(getExecutionEnvironment())) { |
414 |
if (force && ! ConnectionManager.getInstance().isConnectedTo(getExecutionEnvironment())) { |
Lines 556-562
Link Here
|
556 |
if (oldEntry == null) { |
552 |
if (oldEntry == null) { |
557 |
changed = true; |
553 |
changed = true; |
558 |
cacheName = RemoteFileSystemUtils.escapeFileName(newEntry.getName()); |
554 |
cacheName = RemoteFileSystemUtils.escapeFileName(newEntry.getName()); |
559 |
if (loaded) { |
555 |
if (loaded || newEntry.getName().equals(expectedName)) { |
560 |
entriesToFireCreated.add(newEntry); |
556 |
entriesToFireCreated.add(newEntry); |
561 |
} |
557 |
} |
562 |
} else { |
558 |
} else { |
Lines 655-670
Link Here
|
655 |
storageFile.setLastModified(System.currentTimeMillis()); |
651 |
storageFile.setLastModified(System.currentTimeMillis()); |
656 |
if (trace) { trace("set lastModified to {0}", storageFile.lastModified()); } // NOI18N |
652 |
if (trace) { trace("set lastModified to {0}", storageFile.lastModified()); } // NOI18N |
657 |
if (changed) { |
653 |
if (changed) { |
658 |
if (loaded) { |
654 |
for (DirEntry entry : entriesToFireCreated) { |
659 |
for (DirEntry entry : entriesToFireCreated) { |
655 |
RemoteFileObjectBase fo = createFileObject(entry); |
660 |
RemoteFileObjectBase fo = createFileObject(entry); |
656 |
fireRemoteFileObjectCreated(fo, fo.getNameExt().equals(expectedName)); |
661 |
fireRemoteFileObjectCreated(fo); |
|
|
662 |
} |
663 |
} |
657 |
} |
664 |
for (DirEntry entry : entriesToFireChanged) { |
658 |
for (DirEntry entry : entriesToFireChanged) { |
665 |
RemoteFileObjectBase fo = getFileSystem().getFactory().getCachedFileObject(getPath() + '/' + entry.getName()); |
659 |
RemoteFileObjectBase fo = getFileSystem().getFactory().getCachedFileObject(getPath() + '/' + entry.getName()); |
666 |
if (fo != null) { |
660 |
if (fo != null) { |
667 |
fireFileChangedEvent(getListeners(), new FileEvent(fo)); |
661 |
fireFileChangedEvent(fo.getListeners(), new FileEvent(fo, fo)); |
|
|
662 |
fireFileChangedEvent(getListeners(), new FileEvent(this, fo)); |
668 |
} |
663 |
} |
669 |
} |
664 |
} |
670 |
} |
665 |
} |
Lines 760-770
Link Here
|
760 |
} |
755 |
} |
761 |
|
756 |
|
762 |
private void invalidate(DirEntry oldEntry) { |
757 |
private void invalidate(DirEntry oldEntry) { |
763 |
FileObject fo = getFileSystem().getFactory().invalidate(getPath() + '/' + oldEntry.getName()); |
758 |
RemoteFileObjectBase fo = getFileSystem().getFactory().invalidate(getPath() + '/' + oldEntry.getName()); |
764 |
File oldEntryCache = new File(getCache(), oldEntry.getCache()); |
759 |
File oldEntryCache = new File(getCache(), oldEntry.getCache()); |
765 |
removeFile(oldEntryCache); |
760 |
removeFile(oldEntryCache); |
766 |
if (fo != null) { |
761 |
if (fo != null) { |
767 |
fireFileDeletedEvent(getListeners(), new FileEvent(fo)); |
762 |
fireFileDeletedEvent(fo.getListeners(), new FileEvent(fo)); |
|
|
763 |
fireFileDeletedEvent(getListeners(), new FileEvent(this, fo)); |
768 |
} |
764 |
} |
769 |
} |
765 |
} |
770 |
|
766 |
|
Lines 795-806
Link Here
|
795 |
|
791 |
|
796 |
@Override |
792 |
@Override |
797 |
protected void refreshImpl() throws ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
793 |
protected void refreshImpl() throws ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
798 |
refreshDirectoryStorage(); |
794 |
refreshImpl(null); |
|
|
795 |
} |
796 |
|
797 |
private void refreshImpl(String expectedName) throws ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
798 |
refreshDirectoryStorage(expectedName); |
799 |
for (RemoteFileObjectBase child : getExistentChildren()) { |
799 |
for (RemoteFileObjectBase child : getExistentChildren()) { |
800 |
child.refreshImpl(); |
800 |
child.refreshImpl(); |
801 |
} |
801 |
} |
802 |
} |
802 |
} |
803 |
|
803 |
|
804 |
private void trace(String message, Object... args) { |
804 |
private void trace(String message, Object... args) { |
805 |
if (trace) { |
805 |
if (trace) { |
806 |
message = "SYNC [" + getPath() + "][" + System.identityHashCode(this) + "][" + Thread.currentThread().getId() + "]: " + message; // NOI18N |
806 |
message = "SYNC [" + getPath() + "][" + System.identityHashCode(this) + "][" + Thread.currentThread().getId() + "]: " + message; // NOI18N |