mirror of https://github.com/zlatinb/muwire
Only persist downloaded files if sharing thereof is enabled
Otherwise we might inadvertently share downloadspull/37/head
parent
aa56cc23c0
commit
a891c83518
|
@ -262,7 +262,7 @@ public class Core {
|
|||
eventBus.register(UILoadedEvent.class, persisterService)
|
||||
|
||||
log.info "initializing folder persistence service"
|
||||
persisterFolderService = new PersisterFolderService(new File(home, "files"), eventBus)
|
||||
persisterFolderService = new PersisterFolderService(this, new File(home, "files"), eventBus)
|
||||
eventBus.register(PersisterDoneEvent.class, persisterFolderService)
|
||||
eventBus.register(FileDownloadedEvent.class, persisterFolderService)
|
||||
eventBus.register(FileLoadedEvent.class, persisterFolderService)
|
||||
|
|
|
@ -28,6 +28,7 @@ class PersisterFolderService extends BasePersisterService {
|
|||
|
||||
final static int CUT_LENGTH = 6
|
||||
|
||||
private final Core core;
|
||||
final File location
|
||||
final EventBus listener
|
||||
final int interval
|
||||
|
@ -36,7 +37,8 @@ class PersisterFolderService extends BasePersisterService {
|
|||
new Thread(r, "file persister")
|
||||
} as ThreadFactory)
|
||||
|
||||
PersisterFolderService(File location, EventBus listener) {
|
||||
PersisterFolderService(Core core, File location, EventBus listener) {
|
||||
this.core = core;
|
||||
this.location = location
|
||||
this.listener = listener
|
||||
this.interval = interval
|
||||
|
@ -58,7 +60,9 @@ class PersisterFolderService extends BasePersisterService {
|
|||
}
|
||||
|
||||
void onFileDownloadedEvent(FileDownloadedEvent downloadedEvent) {
|
||||
persistFile(downloadedEvent.downloadedFile)
|
||||
if (core.getMuOptions().getShareDownloadedFiles()) {
|
||||
persistFile(downloadedEvent.downloadedFile)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue