0

Проверку директорий осуществляет FileDownloader

This commit is contained in:
2017-04-07 13:00:04 +03:00
parent e0069837b3
commit 67c3f69609
3 changed files with 7 additions and 6 deletions

View File

@@ -26,9 +26,6 @@ public class OnlinelifeScanner implements ScannerCinema {
this.fileDownloader = fileDownloader;
this.browser = browser;
this.saveToDir = saveToDir;
if (!this.saveToDir.mkdirs() && !this.saveToDir.exists()) {
throw new IllegalStateException(String.format("dir not found: '%s'", this.saveToDir.getAbsolutePath()));
}
this.repository = repository;
}

View File

@@ -27,9 +27,6 @@ public class SeasonvarScanner implements ScannerCinema {
this.fileDownloader = fileDownloader;
this.browser = browser;
this.saveTo = saveTo;
if (!this.saveTo.mkdirs() && !this.saveTo.exists()) {
throw new IllegalStateException(String.format("dir not found: '%s'", this.saveTo.getAbsolutePath()));
}
this.repository = repository;
}

View File

@@ -32,6 +32,13 @@ public class FileDownloaderImpl implements FileDownloader, Runnable {
@Override
public void addFile(String url, File saveTo) {
if (!saveTo.getParentFile().exists()) {
if (!saveTo.getParentFile().mkdirs()) {
throw new IllegalStateException(String.format("dir not found: '%s'",
saveTo.getParentFile().getAbsolutePath()));
}
}
try {
listOfEntries.put(new AbstractMap.SimpleEntry<>(url, saveTo));
} catch (InterruptedException ignore) {