From 335b2d81d80a3b06c4757e0bad32a0ad95141021 Mon Sep 17 00:00:00 2001 From: BlyDoesCoding Date: Mon, 20 Mar 2023 21:31:10 +0100 Subject: [PATCH] Update deletion behavior and fixed file == NULL bug --- .idea/workspace.xml | 34 +++++++++++++++++++++------------- src/Main.java | 21 ++++++++++++++------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b1ae776..06e32c9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,7 +10,8 @@ - + + - { - "keyToString": { - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "SHARE_PROJECT_CONFIGURATION_FILES": "true", - "last_opened_file_path": "/home/bly/IdeaProjects/Sherly", - "project.structure.last.edited": "Artifacts", - "project.structure.proportion": "0.15", - "project.structure.side.proportion": "0.2", - "settings.editor.selected.configurable": "vcs.Git" + +}]]> diff --git a/src/Main.java b/src/Main.java index f972eee..2430ac2 100644 --- a/src/Main.java +++ b/src/Main.java @@ -49,7 +49,7 @@ public class Main { System.out.println(" -f / -folder all the folders you want to scan for (see example above!)"); System.out.println(" -c / -color enable colored messages"); System.out.println(" -p / -progress enable progress indicator"); - System.out.println(" -d / -delete delete all found duplicates except one"); + System.out.println(" -d / -delete delete all dups except one without asking first"); System.out.println(" -debug debug stuff"); return; } @@ -119,9 +119,9 @@ public class Main { TimeUnit.SECONDS.sleep(1); if (showProgress && doTheColorThingy) { - System.out.print(ConsoleColors.BLUE_BOLD + "Progress: " + ConsoleColors.GREEN_BOLD + progress + " / " + filesToBeDone + ConsoleColors.RESET + "\r"); + System.out.print(ConsoleColors.BLUE_BOLD + "Progress: " + ConsoleColors.GREEN_BOLD + progress + " / " + filesToBeDone + " | " + (progress * 100 / filesToBeDone) + "%" + ConsoleColors.RESET + "\r"); } else if (showProgress) { - System.out.print("Progress: " + progress + " / " + filesToBeDone + "\r"); + System.out.print("Progress: " + progress + " / " + filesToBeDone + " | " + (progress * 100 / filesToBeDone) + "%" + "\r"); } } @@ -140,7 +140,7 @@ public class Main { } - if (deleteDups) { + List allTheFilesWillBeDeleted = new ArrayList<>(); long bytes = 0; @@ -159,9 +159,14 @@ public class Main { - ask(doTheColorThingy, bytes, allTheFilesWillBeDeleted); + if (deleteDups) { + delete(allTheFilesWillBeDeleted); + } else { + ask(doTheColorThingy, bytes, allTheFilesWillBeDeleted); + } + + - } } //print files and ask user @@ -188,7 +193,9 @@ public class Main { public static void delete(List deleteThem) { for (Path file : deleteThem) { - file.toFile().delete(); + if (file != null) {file.toFile().delete();} + + } }