Fixed another Random Crash that happened when a file size is near 0

This commit is contained in:
bly 2023-01-05 00:23:04 +01:00
parent f32e5225cb
commit 553adbb9b6
2 changed files with 16 additions and 10 deletions

21
.idea/workspace.xml generated
View file

@ -9,14 +9,9 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="test"> <list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="fixed A bug where it just randomly crashes and added the ability to delete duplicate files with -d paramater">
<change afterPath="$PROJECT_DIR$/.idea/artifacts/Sherly_jar.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/META-INF/MANIFEST.MF" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ConsoleColors.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ConsoleColors.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ThreadedCompare.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ThreadedCompare.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -65,7 +60,7 @@
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" /> <option name="MAIN_CLASS_NAME" value="Main" />
<module name="Sherly" /> <module name="Sherly" />
<option name="PROGRAM_PARAMETERS" value="-c -f $USER_HOME$/Pictures/ -p -d" /> <option name="PROGRAM_PARAMETERS" value="-f $USER_HOME$/Pictures/ -p -d" />
<method v="2"> <method v="2">
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
</method> </method>
@ -141,7 +136,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1672749718265</updated> <updated>1672749718265</updated>
</task> </task>
<option name="localTasksCounter" value="9" /> <task id="LOCAL-00009" summary="fixed A bug where it just randomly crashes and added the ability to delete duplicate files with -d paramater">
<created>1672798827144</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1672798827144</updated>
</task>
<option name="localTasksCounter" value="10" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -173,7 +175,8 @@
<MESSAGE value="Removing not needed lines" /> <MESSAGE value="Removing not needed lines" />
<MESSAGE value="Fixed Duplicates in HashMap" /> <MESSAGE value="Fixed Duplicates in HashMap" />
<MESSAGE value="test" /> <MESSAGE value="test" />
<option name="LAST_COMMIT_MESSAGE" value="test" /> <MESSAGE value="fixed A bug where it just randomly crashes and added the ability to delete duplicate files with -d paramater" />
<option name="LAST_COMMIT_MESSAGE" value="fixed A bug where it just randomly crashes and added the ability to delete duplicate files with -d paramater" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View file

@ -129,7 +129,10 @@ public class Main {
for (String md5: fileMap.keySet()) { for (String md5: fileMap.keySet()) {
Main.fileMap.get(md5).remove(0); Main.fileMap.get(md5).remove(0);
for (Path file: Main.fileMap.get(md5)) { for (Path file: Main.fileMap.get(md5)) {
bytes += file.toFile().length(); if (file != null) {
bytes += file.toFile().length();
}
} }
allTheFilesWillBeDeleted.addAll(Main.fileMap.get(md5)); allTheFilesWillBeDeleted.addAll(Main.fileMap.get(md5));