Removed options to delete duplicates

This commit is contained in:
Julian Müller (ChaoticByte) 2023-05-07 17:47:08 +02:00
parent a717146d73
commit 2770390df3
3 changed files with 8 additions and 53 deletions

View file

@ -1,6 +1,7 @@
# xxSherly # 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) ![](./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. 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)). 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. That's why the checksum is composed of the xxHash Digest and the filesize. 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
``` ```
usage: xxSherly.jar [options] folder1 folder2 ... usage: xxSherly.jar [options] folder1 folder2 ...
-c,--color enable colored output -c,--color enable colored output
-d,--delete delete all dups except one, without asking first
-h,--help show this help message -h,--help show this help message
-n,--noinput skip all user input
-p,--progress enable progress indicator -p,--progress enable progress indicator
-t,--threads <arg> override default thread number (defaults to the -t,--threads <arg> override default thread number (defaults to the
number of cores) number of cores)
@ -42,16 +41,16 @@ mvn package assembly:single
## Speed comparison ## 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 ```bash
time java -jar Bin/sherly.jar -n -f ~/Music/ 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`). 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 | | 1st run | 4.055s | 2.561s |
| 2nd run | 4.055s | 2.304s | | 2nd run | 4.055s | 2.304s |

View file

@ -6,7 +6,7 @@
<groupId>net.chaoticbyte.xxsherly</groupId> <groupId>net.chaoticbyte.xxsherly</groupId>
<artifactId>xxSherly</artifactId> <artifactId>xxSherly</artifactId>
<version>2.0</version> <version>2.1</version>
<name>xxSherly</name> <name>xxSherly</name>
<!-- FIXME change it to the project's website --> <!-- FIXME change it to the project's website -->

View file

@ -7,7 +7,6 @@ import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Scanner;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -32,9 +31,7 @@ public class App {
// Arguments // Arguments
List<File> folderList = new ArrayList<>(); List<File> folderList = new ArrayList<>();
boolean showProgress = false; boolean showProgress = false;
boolean deleteDups = false;
boolean verbose = false; boolean verbose = false;
boolean noInput = false;
boolean displayHelp = false; boolean displayHelp = false;
int requestedThreads = 0; int requestedThreads = 0;
@ -46,8 +43,6 @@ public class App {
commandlineOptions.addOption("c", "color", false, "enable colored output"); 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("t", "threads", true, "override default thread number (defaults to the number of cores)");
commandlineOptions.addOption("p", "progress", false, "enable progress indicator"); 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("v", "verbose", false, "more verbose output");
commandlineOptions.addOption("h", "help", false, "show this help message"); commandlineOptions.addOption("h", "help", false, "show this help message");
@ -62,9 +57,7 @@ public class App {
// Get arguments & options // Get arguments & options
doTheColorThingy = arguments.hasOption("c"); doTheColorThingy = arguments.hasOption("c");
showProgress = arguments.hasOption("p"); showProgress = arguments.hasOption("p");
deleteDups = arguments.hasOption("d");
verbose = arguments.hasOption("v"); verbose = arguments.hasOption("v");
noInput = arguments.hasOption("n");
displayHelp = arguments.hasOption("h"); displayHelp = arguments.hasOption("h");
requestedThreads = Integer.parseInt(arguments.getOptionValue("t", "0")); requestedThreads = Integer.parseInt(arguments.getOptionValue("t", "0"));
} }
@ -90,7 +83,6 @@ public class App {
System.out.println("Arguments:");; System.out.println("Arguments:");;
System.out.println(" Folders: " + folderList.size()); System.out.println(" Folders: " + folderList.size());
System.out.println(" Color: " + doTheColorThingy); System.out.println(" Color: " + doTheColorThingy);
System.out.println(" Delete: " + deleteDups);
System.out.println(" Progress: " + showProgress); System.out.println(" Progress: " + showProgress);
} }
@ -187,41 +179,5 @@ public class App {
if (fileMap.size() < 1) color = ConsoleColors.GREEN_BOLD; 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); 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."); } 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<File> 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());
}
}
} }
} }