platform: better pairing of before/after VFS events

This commit is contained in:
Roman Shevchenko
2013-11-08 10:26:54 +01:00
parent 97aec30fa7
commit eaeed33efc
@@ -635,20 +635,19 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
final Object requestor,
final long modStamp,
final long timeStamp) throws IOException {
final VFileContentChangeEvent event = new VFileContentChangeEvent(requestor, file, file.getModificationStamp(), modStamp, false);
final List<VFileContentChangeEvent> events = Collections.singletonList(event);
final BulkFileListener publisher = myEventsBus.syncPublisher(VirtualFileManager.VFS_CHANGES);
publisher.before(events);
return new ByteArrayOutputStream() {
private boolean closed; // protection against user calling .close() twice
@Override
public void close() throws IOException {
if (closed) return;
super.close();
VFileContentChangeEvent event = new VFileContentChangeEvent(requestor, file, file.getModificationStamp(), modStamp, false);
List<VFileContentChangeEvent> events = Collections.singletonList(event);
BulkFileListener publisher = myEventsBus.syncPublisher(VirtualFileManager.VFS_CHANGES);
publisher.before(events);
NewVirtualFileSystem delegate = getDelegate(file);
OutputStream ioFileStream = delegate.getOutputStream(file, requestor, modStamp, timeStamp);
// FSRecords.ContentOutputStream already buffered, no need to wrap in BufferedStream
@@ -665,6 +664,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
closed = true;
persistenceStream.close();
ioFileStream.close();
executeTouch(file, false, event.getModificationStamp());
publisher.after(events);
}