slight improves
This commit is contained in:
parent
7241986b99
commit
d093e0cc35
|
@ -21,8 +21,8 @@ public class ConfigLoader extends CommonConfigFileLoader<ConfigLoader.ProjectCon
|
|||
return getLoader().getConfig(configParam);
|
||||
}
|
||||
|
||||
public static boolean isDisabled(ProjectConfiguration configParam) {
|
||||
return !"true".equals(get(configParam));
|
||||
public static boolean isEnabled(ProjectConfiguration configParam) {
|
||||
return get(configParam).equals("true");
|
||||
}
|
||||
|
||||
public enum ProjectConfiguration {
|
||||
|
|
|
@ -59,7 +59,7 @@ class FailedImportFixer {
|
|||
|
||||
private List<Path> getVideoFilesFrom(Path path) throws IOException {
|
||||
if (!Files.exists(path)) {
|
||||
System.out.printf("path %s doesn't exist on the filesystem", path);
|
||||
System.out.printf("path %s doesn't exist on the filesystem%n", path);
|
||||
return List.of();
|
||||
}
|
||||
System.out.println("going to explore "+path);
|
||||
|
|
|
@ -14,7 +14,7 @@ class FileCopier {
|
|||
try {
|
||||
createDestinationFolderIfApply(destination);
|
||||
|
||||
if (ConfigLoader.isDisabled(TEST_MODE))
|
||||
if (!ConfigLoader.isEnabled(TEST_MODE))
|
||||
Files.createLink(destination, source);
|
||||
} catch (IOException e) {
|
||||
System.out.printf("error when creating hardlink with destination %s, error: %s%n",
|
||||
|
@ -27,7 +27,7 @@ class FileCopier {
|
|||
var destinationFolder = destinationFile.getParent();
|
||||
if (isTemporaryDestination(destinationFolder) && !Files.exists(destinationFolder)) {
|
||||
System.out.printf("destination folder %s will be created", destinationFolder);
|
||||
if (ConfigLoader.isDisabled(TEST_MODE))
|
||||
if (!ConfigLoader.isEnabled(TEST_MODE))
|
||||
Files.createDirectories(destinationFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import tv.mangrana.config.ConfigLoader;
|
|||
import tv.mangrana.exception.IncorrectWorkingReferencesException;
|
||||
import tv.mangrana.sonarr.Sonarr;
|
||||
|
||||
import static tv.mangrana.config.ConfigLoader.ProjectConfiguration.TEST_MODE;
|
||||
|
||||
public class MainWorker {
|
||||
|
||||
private final QueueFixer queueFixer;
|
||||
|
@ -15,6 +17,9 @@ public class MainWorker {
|
|||
|
||||
private MainWorker() throws IncorrectWorkingReferencesException {
|
||||
var configLoader = ConfigLoader.getLoader();
|
||||
if (ConfigLoader.isEnabled(TEST_MODE))
|
||||
System.out.println("ATTENTION! TEST MODE ENABLED. No folders will be created nor files copied.");
|
||||
|
||||
Sonarr.initService(configLoader);
|
||||
queueFixer = new QueueFixer();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ class MissingFilesDetector {
|
|||
private Map<Long, List<Path>> torrentFilesByLength;
|
||||
|
||||
List<Path> getMissingFilesAtDestination(List<Path> torrentFiles, List<Path> sonarrFiles) {
|
||||
if (sonarrFiles.size() == 0) {
|
||||
System.out.println("All files are missing at destination");
|
||||
return torrentFiles;
|
||||
}
|
||||
System.out.printf("going to compare %d torrent files with %d sonar files%n",
|
||||
torrentFiles.size(), sonarrFiles.size());
|
||||
digestTorrentFiles(torrentFiles);
|
||||
|
|
|
@ -67,7 +67,7 @@ public class QueueFixer {
|
|||
private void cleanWorkedElementsFromQueue(List<Record> sonarQueue, List<Record> recordsToFix) {
|
||||
List<String> workedTitles = mapRecord2Title(recordsToFix);
|
||||
List<Integer> recordIds2Delete = filterPresentTitlesFromQueue(sonarQueue, workedTitles);
|
||||
if (ConfigLoader.isDisabled(TEST_MODE))
|
||||
if (!ConfigLoader.isEnabled(TEST_MODE))
|
||||
sonarrApiGateway.deleteQueueElements(recordIds2Delete);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue