Update deletion behavior and fixed file == NULL bug
This commit is contained in:
parent
6ade226c89
commit
335b2d81d8
2 changed files with 35 additions and 20 deletions
34
.idea/workspace.xml
generated
34
.idea/workspace.xml
generated
|
@ -10,7 +10,8 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="Rework of README.md">
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -54,18 +55,18 @@
|
|||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"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"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"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": "Settings.Markdown"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RunAnythingCache">
|
||||
<option name="myCommands">
|
||||
<command value="github" />
|
||||
|
@ -200,7 +201,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1679341913990</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="16" />
|
||||
<task id="LOCAL-00016" summary="Rework of README.md">
|
||||
<created>1679341943299</created>
|
||||
<option name="number" value="00016" />
|
||||
<option name="presentableId" value="LOCAL-00016" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1679341943299</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="17" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
|
@ -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<Path> allTheFilesWillBeDeleted = new ArrayList<>();
|
||||
|
||||
long bytes = 0;
|
||||
|
@ -159,10 +159,15 @@ public class Main {
|
|||
|
||||
|
||||
|
||||
if (deleteDups) {
|
||||
delete(allTheFilesWillBeDeleted);
|
||||
} else {
|
||||
ask(doTheColorThingy, bytes, allTheFilesWillBeDeleted);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//print files and ask user
|
||||
public static void ask(boolean color, long bytes, List<Path> deleteThem) {
|
||||
|
@ -188,7 +193,9 @@ public class Main {
|
|||
|
||||
public static void delete(List<Path> deleteThem) {
|
||||
for (Path file : deleteThem) {
|
||||
file.toFile().delete();
|
||||
if (file != null) {file.toFile().delete();}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue