diff options
author | Keuin <[email protected]> | 2021-01-22 21:59:27 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2021-01-22 21:59:27 +0800 |
commit | 4ac575330130ac4e1b4b35386ffc0aacd431a5a4 (patch) | |
tree | c5b7c484b38b4b4cc0ffa3c7ac93b3c513f86f7a | |
parent | 781c8268e53a75c6d54b5305ed7a6b94c58a9c0d (diff) |
BugFix: `/kb list` or `/kb` shows `null` for all incremental backups.1.4.5
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/KBCommands.java | 22 | ||||
-rw-r--r-- | src/main/resources/fabric.mod.json | 2 |
3 files changed, 23 insertions, 3 deletions
diff --git a/gradle.properties b/gradle.properties index 6e44a42..8f29ad1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.14.4 yarn_mappings=1.14.4+build.18 loader_version=0.11.0 # Mod Properties -mod_version=1.4.4 +mod_version=1.4.5 maven_group=com.keuin.kbackupfabric archives_base_name=kbackup-fabric # Dependencies diff --git a/src/main/java/com/keuin/kbackupfabric/KBCommands.java b/src/main/java/com/keuin/kbackupfabric/KBCommands.java index 90a4130..9f00790 100644 --- a/src/main/java/com/keuin/kbackupfabric/KBCommands.java +++ b/src/main/java/com/keuin/kbackupfabric/KBCommands.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.function.Function; import static com.keuin.kbackupfabric.backup.BackupFilesystemUtil.*; import static com.keuin.kbackupfabric.util.PrintUtil.*; @@ -90,6 +91,18 @@ public final class KBCommands { || name.toLowerCase().endsWith(".kbi")) ); + Function<File, String> backupInformationProvider = new Function<File, String>() { + @Override + public String apply(File file) { + Objects.requireNonNull(file); + if (file.getName().toLowerCase().endsWith(".zip")) + return getPrimitiveBackupInformationString(file.getName(), file.length()); + else if (file.getName().toLowerCase().endsWith(".kbi")) + return getIncrementalBackupInformationString(file.getName()); + return file.getName(); + } + }; + synchronized (backupFileNameList) { backupFileNameList.clear(); if (files != null) { @@ -102,7 +115,7 @@ public final class KBCommands { for (File file : files) { ++i; String backupFileName = file.getName(); - msgInfo(context, String.format("[%d] %s", i, getPrimitiveBackupInformationString(backupFileName, file.length()))); + msgInfo(context, String.format("[%d] %s", i, backupInformationProvider.apply(file))); backupFileNameList.add(backupFileName); } } else { @@ -383,6 +396,13 @@ public final class KBCommands { ); } + private static String getIncrementalBackupInformationString(String backupFileName) { + return String.format( + "(Incremental) %s", + new IncrementalBackupFileNameEncoder().decode(backupFileName) + ); + } + // /** // * Select the backup method we use. // * @param context the context. diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ce26dd2..e2d9d39 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -13,7 +13,7 @@ }, "license": "GPL V3", "icon": "assets/kbackupfabric/icon.png", - "environment": "*", + "environment": "server", "entrypoints": { "main": [ "com.keuin.kbackupfabric.KBPluginEvents" |