diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 529138e..90de5ec 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,9 @@
-
+
-
-
+
@@ -30,12 +29,12 @@
- {
+ "keyToString": {
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true"
}
-}]]>
+}
@@ -73,7 +72,14 @@
1672703881482
-
+
+ 1672704560597
+
+
+
+ 1672704560597
+
+
@@ -102,6 +108,7 @@
-
+
+
\ No newline at end of file
diff --git a/src/ThreadedCompare.java b/src/ThreadedCompare.java
index 22c2d24..3390401 100644
--- a/src/ThreadedCompare.java
+++ b/src/ThreadedCompare.java
@@ -20,21 +20,17 @@ public class ThreadedCompare extends Thread {
for (Path file2 : pathsToCompareTo) {
try {
if (sameContent(file1, file2)) {
- List bothPaths = new ArrayList<>();
- bothPaths.add(file1);
- bothPaths.add(file2);
+ List bothList = new ArrayList<>();
+
+ bothList.add(file1);
+ bothList.add(file2);
//here it is trying to add the values in the HashMap
- if (Main.fileMap.containsKey(getMD5Sum(file1.toFile()))) {
- if (!Main.fileMap.get(getMD5Sum(file1.toFile())).contains(file1)) {
- Main.fileMap.get(getMD5Sum(file1.toFile())).add(file1);
- }
- if (!Main.fileMap.get(getMD5Sum(file1.toFile())).contains(file2)) {
- Main.fileMap.get(getMD5Sum(file1.toFile())).add(file2);
- }
- } else {
- Main.fileMap.put(getMD5Sum(file1.toFile()), bothPaths);
- }
+ Main.fileMap.putIfAbsent(getMD5Sum(file1.toFile()), bothList);
+
+ Main.fileMap.get(getMD5Sum(file1.toFile())).removeAll(bothList);
+ Main.fileMap.get(getMD5Sum(file1.toFile())).addAll(bothList);
+
}
} catch (IOException e) {
throw new RuntimeException(e);