Skip to content

Commit

Permalink
BugFix: /kb list or /kb shows null for all incremental backups.
Browse files Browse the repository at this point in the history
  • Loading branch information
keuin committed Jan 22, 2021
1 parent 781c826 commit 4ac5753
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/com/keuin/kbackupfabric/KBCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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.*;
Expand Down Expand Up @@ -90,6 +91,18 @@ public static int list(CommandContext<ServerCommandSource> context) {
|| 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) {
Expand All @@ -102,7 +115,7 @@ public static int list(CommandContext<ServerCommandSource> context) {
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 {
Expand Down Expand Up @@ -383,6 +396,13 @@ private static String getPrimitiveBackupInformationString(String backupFileName,
);
}

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.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"license": "GPL V3",
"icon": "assets/kbackupfabric/icon.png",
"environment": "*",
"environment": "server",
"entrypoints": {
"main": [
"com.keuin.kbackupfabric.KBPluginEvents"
Expand Down

0 comments on commit 4ac5753

Please sign in to comment.