mirror of https://github.com/zlatinb/muwire
make modified file a multi-file event
parent
db221b4501
commit
8fa96432a9
|
@ -196,7 +196,7 @@ class DirectoryWatcher {
|
|||
SharedFile sf = fileManager.fileToSharedFile.get(file)
|
||||
if (sf != null) {
|
||||
log.fine ("modified shared $file")
|
||||
eventBus.publish(new FileModifiedEvent(sharedFile: sf))
|
||||
eventBus.publish(new FileModifiedEvent(sharedFiles: [sf]))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,8 @@ class FileManager {
|
|||
}
|
||||
|
||||
void onFileModifiedEvent(FileModifiedEvent event) {
|
||||
unshareFile(event.sharedFile, false)
|
||||
for(SharedFile sf : event.sharedFiles)
|
||||
unshareFile(sf, false)
|
||||
}
|
||||
|
||||
private void unshareFile(SharedFile sf, boolean deleted) {
|
||||
|
|
|
@ -4,5 +4,5 @@ import com.muwire.core.Event
|
|||
import com.muwire.core.SharedFile
|
||||
|
||||
class FileModifiedEvent extends Event {
|
||||
SharedFile sharedFile
|
||||
SharedFile[] sharedFiles
|
||||
}
|
||||
|
|
|
@ -97,9 +97,11 @@ class HasherService {
|
|||
}
|
||||
|
||||
void onFileModifiedEvent(FileModifiedEvent event) {
|
||||
File f = event.sharedFile.getFile()
|
||||
File canonical = f.getCanonicalFile()
|
||||
throttlerExecutor.execute({throttle(f, canonical, true)})
|
||||
for (SharedFile sharedFile : event.sharedFiles) {
|
||||
File f = sharedFile.getFile()
|
||||
File canonical = f.getCanonicalFile()
|
||||
throttlerExecutor.execute({ throttle(f, canonical, true) })
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void throttle(File f, File canonical, boolean forceHash) {
|
||||
|
|
|
@ -148,9 +148,9 @@ class PersisterFolderService extends BasePersisterService {
|
|||
}
|
||||
|
||||
void onFileModifiedEvent(FileModifiedEvent event) {
|
||||
persisterExecutor.submit( {
|
||||
unshareFile(event.sharedFile)
|
||||
} as Runnable)
|
||||
// shortcut
|
||||
def unsharedEvent = new FileUnsharedEvent(unsharedFiles: event.sharedFiles)
|
||||
onFileUnsharedEvent(unsharedEvent)
|
||||
}
|
||||
|
||||
private void unshareFile(SharedFile sharedFile) {
|
||||
|
|
|
@ -615,7 +615,7 @@ class MainFrameModel {
|
|||
void onFileModifiedEvent(FileModifiedEvent event) {
|
||||
// shortcut
|
||||
FileUnsharedEvent e = new FileUnsharedEvent(
|
||||
unsharedFiles: new SharedFile[]{event.sharedFile},
|
||||
unsharedFiles: event.sharedFiles,
|
||||
deleted: false,
|
||||
implicit: false
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue