summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-01-21 01:50:08 +0800
committerKeuin <[email protected]>2021-01-21 01:50:08 +0800
commitac3b5e1476dedcefb723f19bd0fdd9a22fcb16e9 (patch)
tree75d0994f3f7aa37c3d240933f0f2d179d318e597 /src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java
parent82e3986045ac7eaca6aaa290fb2283fd6c6c901a (diff)
parent7a5297de3467b1069fdf5e4a1b2aaf510ca35663 (diff)
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/com/keuin/kbackupfabric/operation/backup/PrimitiveBackupMethod.java
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java
index 444ca9a..3ae09f5 100644
--- a/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java
+++ b/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java
@@ -1,8 +1,8 @@
package com.keuin.kbackupfabric.operation;
import com.keuin.kbackupfabric.operation.abstracts.InvokableAsyncBlockingOperation;
-import com.keuin.kbackupfabric.util.backup.suggestion.BackupNameSuggestionProvider;
import com.keuin.kbackupfabric.util.PrintUtil;
+import com.keuin.kbackupfabric.util.backup.suggestion.BackupNameSuggestionProvider;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
@@ -10,27 +10,26 @@ import net.minecraft.server.command.ServerCommandSource;
import java.io.File;
import java.io.IOException;
-import static com.keuin.kbackupfabric.util.backup.BackupFilesystemUtil.getBackupFileName;
-import static com.keuin.kbackupfabric.util.backup.BackupFilesystemUtil.getBackupSaveDirectory;
import static com.keuin.kbackupfabric.util.PrintUtil.msgErr;
import static com.keuin.kbackupfabric.util.PrintUtil.msgInfo;
+import static com.keuin.kbackupfabric.util.backup.BackupFilesystemUtil.getBackupSaveDirectory;
import static org.apache.commons.io.FileUtils.forceDelete;
public class DeleteOperation extends InvokableAsyncBlockingOperation {
//private static final Logger LOGGER = LogManager.getLogger();
- private final String backupName;
+ private final String backupFileName;
private final CommandContext<ServerCommandSource> context;
- public DeleteOperation(CommandContext<ServerCommandSource> context, String backupName) {
+ public DeleteOperation(CommandContext<ServerCommandSource> context, String backupFileName) {
super("BackupDeletingWorker");
- this.backupName = backupName;
+ this.backupFileName = backupFileName;
this.context = context;
}
@Override
public String toString() {
- return String.format("deletion of %s", backupName);
+ return String.format("deletion of %s", backupFileName);
}
@Override
@@ -41,8 +40,7 @@ public class DeleteOperation extends InvokableAsyncBlockingOperation {
private void delete() {
MinecraftServer server = context.getSource().getMinecraftServer();
- String backupFileName = getBackupFileName(backupName);
- PrintUtil.info("Deleting backup " + backupName);
+ PrintUtil.info("Deleting backup file " + this.backupFileName);
File backupFile = new File(getBackupSaveDirectory(server), backupFileName);
int tryCounter = 0;
do {
@@ -59,7 +57,7 @@ public class DeleteOperation extends InvokableAsyncBlockingOperation {
}
++tryCounter;
} while (backupFile.exists());
- PrintUtil.info("Deleted backup " + backupName);
- msgInfo(context, "Deleted backup " + backupName);
+ PrintUtil.info("Successfully deleted backup file " + this.backupFileName);
+ msgInfo(context, "Successfully deleted backup file " + this.backupFileName);
}
}