From 2770390df31667eb9c93bd812db65fc7d35facf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller=20=28ChaoticByte=29?= Date: Sun, 7 May 2023 17:47:08 +0200 Subject: [PATCH] Removed options to delete duplicates --- README.md | 15 +++---- pom.xml | 2 +- .../java/net/chaoticbyte/xxsherly/App.java | 44 ------------------- 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index eb20f27..4a26ac2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # xxSherly -A fork of [Sherly](https://github.com/BlyDoesCoding/Sherly), using [xxHash](https://github.com/Cyan4973/xxHash). +A fork of [Sherly](https://github.com/BlyDoesCoding/Sherly), using [xxHash](https://github.com/Cyan4973/xxHash). +This fork is faster, but has less features and may produce false-positives. ![](./images/screenshot.png) @@ -8,17 +9,15 @@ A fork of [Sherly](https://github.com/BlyDoesCoding/Sherly), using [xxHash](http Sherly is a Multithreaded Duplicate File Finder for your Terminal, written in java. You can Easily find duplicate Images, videos as well as any other type of Data. That can be helpful if you run on small storage or just want to keep regular housekeeping. -This fork uses [xxHash](https://github.com/Cyan4973/xxHash) instead of MD5 for performance reasons (see [Speed comparison](#speed-comparison)). -Note that xxHash is not a cryptographic hash function and therefore may produce collisions. That's why the checksum is composed of the xxHash Digest and the filesize. +Instead of md5, this fork uses [xxHash](https://github.com/Cyan4973/xxHash) + the filesize to find duplicates, for performance reasons (see [Speed comparison](#speed-comparison)). +Note that xxHash is not a cryptographic hash function and therefore may produce collisions (false-positives). For this reason, since version 2.1, the program no longer offers the option to delete duplicates. You should delete them by yourself. ## Usage ``` usage: xxSherly.jar [options] folder1 folder2 ... -c,--color enable colored output - -d,--delete delete all dups except one, without asking first -h,--help show this help message - -n,--noinput skip all user input -p,--progress enable progress indicator -t,--threads override default thread number (defaults to the number of cores) @@ -42,16 +41,16 @@ mvn package assembly:single ## Speed comparison -I let Sherly v1.1.4 and xxSherly v1.0 find duplicates in my Music Library (containing `.wav` files) using the following commands: +I let Sherly and xxSherly find duplicates in my Music Library (containing `.wav` files) using the following commands: ```bash time java -jar Bin/sherly.jar -n -f ~/Music/ -time java -jar target/xxSherly-1.0-jar-with-dependencies.jar -n -f ~/Music/ +time java -jar target/xxSherly-x.y-jar-with-dependencies.jar -n -f ~/Music/ ``` The timings are measured using the Linux tool `time` (`real`). -| | Sherly | xxSherly | +| | Sherly v1.1.4 | xxSherly v1.0 | | --------: | ------------: | --------------: | | 1st run | 4.055s | 2.561s | | 2nd run | 4.055s | 2.304s | diff --git a/pom.xml b/pom.xml index 28128ba..46b9f95 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.chaoticbyte.xxsherly xxSherly - 2.0 + 2.1 xxSherly diff --git a/src/main/java/net/chaoticbyte/xxsherly/App.java b/src/main/java/net/chaoticbyte/xxsherly/App.java index b35eae4..c2ef3ed 100644 --- a/src/main/java/net/chaoticbyte/xxsherly/App.java +++ b/src/main/java/net/chaoticbyte/xxsherly/App.java @@ -7,7 +7,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Scanner; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -32,9 +31,7 @@ public class App { // Arguments List folderList = new ArrayList<>(); boolean showProgress = false; - boolean deleteDups = false; boolean verbose = false; - boolean noInput = false; boolean displayHelp = false; int requestedThreads = 0; @@ -46,8 +43,6 @@ public class App { commandlineOptions.addOption("c", "color", false, "enable colored output"); commandlineOptions.addOption("t", "threads", true, "override default thread number (defaults to the number of cores)"); commandlineOptions.addOption("p", "progress", false, "enable progress indicator"); - commandlineOptions.addOption("d", "delete", false, "delete all dups except one, without asking first"); - commandlineOptions.addOption("n", "noinput", false, "skip all user input"); commandlineOptions.addOption("v", "verbose", false, "more verbose output"); commandlineOptions.addOption("h", "help", false, "show this help message"); @@ -62,9 +57,7 @@ public class App { // Get arguments & options doTheColorThingy = arguments.hasOption("c"); showProgress = arguments.hasOption("p"); - deleteDups = arguments.hasOption("d"); verbose = arguments.hasOption("v"); - noInput = arguments.hasOption("n"); displayHelp = arguments.hasOption("h"); requestedThreads = Integer.parseInt(arguments.getOptionValue("t", "0")); } @@ -90,7 +83,6 @@ public class App { System.out.println("Arguments:");; System.out.println(" Folders: " + folderList.size()); System.out.println(" Color: " + doTheColorThingy); - System.out.println(" Delete: " + deleteDups); System.out.println(" Progress: " + showProgress); } @@ -187,41 +179,5 @@ public class App { if (fileMap.size() < 1) color = ConsoleColors.GREEN_BOLD; System.out.println(color + (bytes / 1000000.0) + " unnecessary MB in " + toBeDeleted.size() + " file(s) found." + ConsoleColors.RESET); } else System.out.println((bytes / 1000000.0) + " unnecessary MB in " + toBeDeleted.size() + " file(s) found."); - - // Don't go further if there is nothing to delete - if (fileMap.size() < 1) return; - - if (deleteDups) { - System.out.println(); - delete(toBeDeleted); - } else if (!noInput) { - // Ask if the user wants to delete the file - Scanner input = new Scanner(System.in); - while (true) { - if (doTheColorThingy) System.out.print(ConsoleColors.RED_BOLD + "Do you want to delete them? [y/n] " + ConsoleColors.RESET); - else System.out.print("Do you want to delete them? [y/n] "); - String answer = input.next(); - if (answer.toLowerCase().contains("y")) { - System.out.println(); - delete(toBeDeleted); - break; - } - else if (answer.toLowerCase().contains("n")) break; - } - input.close(); - } - } - - public static void delete(List fileList) { - for (File file : fileList) if (file != null) { - if (file.delete()) { - if (doTheColorThingy) System.out.println(ConsoleColors.RED_BOLD + "Deleted " + file.toPath() + ConsoleColors.RESET); - else System.out.println("Deleted " + file.toPath()); - } - else { - if (doTheColorThingy) System.err.println(ConsoleColors.RED_BOLD + "Couldn't delete " + ConsoleColors.RESET + file.toPath()); - else System.err.println("Couldn't delete " + file.toPath()); - } - } } }