summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util/backup/formatter
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-01-13 12:51:15 +0800
committerkeuin <[email protected]>2021-01-13 12:51:15 +0800
commit81497ebee2cdb0dac3bcdc26c5d77d06bdb98b5d (patch)
tree9e7aad680a438b845126b266374155c8fb306179 /src/main/java/com/keuin/kbackupfabric/util/backup/formatter
parentf4d926c1eb91749a4b0f89c7a35538821ff7e21b (diff)
Clean old incremental backup codes.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/backup/formatter')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/backup/formatter/BackupFileNameFormatter.java31
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/backup/formatter/ObjectTreeBackupFileNameFormatter.java44
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/backup/formatter/PrimitiveZipBackupFileNameFormatter.java43
3 files changed, 0 insertions, 118 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/BackupFileNameFormatter.java b/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/BackupFileNameFormatter.java
deleted file mode 100644
index a437629..0000000
--- a/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/BackupFileNameFormatter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.keuin.kbackupfabric.util.backup.formatter;
-
-import com.keuin.kbackupfabric.util.backup.BackupNameTimeFormatter;
-
-import java.time.LocalDateTime;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public interface BackupFileNameFormatter {
-
- BackupFileName format(String fileName);
-
- class BackupFileName {
- public final LocalDateTime time;
- public final String name;
-
- public BackupFileName(LocalDateTime time, String name) {
- this.time = time;
- this.name = name;
- }
- }
-
- static BackupFileNameFormatter objectTreeBackup() {
- return ObjectTreeBackupFileNameFormatter.getInstance();
- }
-
- static BackupFileNameFormatter primitiveZipBackup() {
- return PrimitiveZipBackupFileNameFormatter.getInstance();
- }
-
-}
diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/ObjectTreeBackupFileNameFormatter.java b/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/ObjectTreeBackupFileNameFormatter.java
deleted file mode 100644
index 08805b2..0000000
--- a/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/ObjectTreeBackupFileNameFormatter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.keuin.kbackupfabric.util.backup.formatter;
-
-import com.keuin.kbackupfabric.util.backup.BackupFilesystemUtil;
-import com.keuin.kbackupfabric.util.backup.BackupNameTimeFormatter;
-import org.spongepowered.asm.mixin.Overwrite;
-
-import java.time.LocalDateTime;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ObjectTreeBackupFileNameFormatter implements BackupFileNameFormatter {
-
- private static final ObjectTreeBackupFileNameFormatter instance = new ObjectTreeBackupFileNameFormatter();
-
- public static ObjectTreeBackupFileNameFormatter getInstance() {
- return instance;
- }
-
- @Override
- public BackupFileNameFormatter.BackupFileName format(String fileName) {
- LocalDateTime time = getTime(fileName);
- String name = getBackupName(fileName);
- return new BackupFileNameFormatter.BackupFileName(time,name);
- }
-
- private LocalDateTime getTime(String fileName) {
- Matcher matcher = Pattern.compile("[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}").matcher(fileName);
- if (matcher.find()) {
- String timeString = matcher.group(0);
- return BackupNameTimeFormatter.timeStringToLocalDateTime(timeString);
- }
- return null;
- }
-
- private String getBackupName(String backupFileName) {
- try {
- if (backupFileName.matches(BackupFilesystemUtil.getBackupFileNamePrefix() + ".+\\.json"))
- return backupFileName.substring(BackupFilesystemUtil.getBackupFileNamePrefix().length(), backupFileName.length() - 4);
- } catch (IndexOutOfBoundsException ignored) {
- }
- return backupFileName;
- }
-
-}
diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/PrimitiveZipBackupFileNameFormatter.java b/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/PrimitiveZipBackupFileNameFormatter.java
deleted file mode 100644
index 2d50d17..0000000
--- a/src/main/java/com/keuin/kbackupfabric/util/backup/formatter/PrimitiveZipBackupFileNameFormatter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.keuin.kbackupfabric.util.backup.formatter;
-
-import com.keuin.kbackupfabric.util.backup.BackupFilesystemUtil;
-import com.keuin.kbackupfabric.util.backup.BackupNameTimeFormatter;
-
-import java.time.LocalDateTime;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class PrimitiveZipBackupFileNameFormatter implements BackupFileNameFormatter {
-
- private static final PrimitiveZipBackupFileNameFormatter instance = new PrimitiveZipBackupFileNameFormatter();
-
- public static PrimitiveZipBackupFileNameFormatter getInstance() {
- return instance;
- }
-
- @Override
- public BackupFileNameFormatter.BackupFileName format(String fileName) {
- LocalDateTime time = getTime(fileName);
- String name = getBackupName(fileName);
- return new BackupFileNameFormatter.BackupFileName(time,name);
- }
-
- private LocalDateTime getTime(String fileName) {
- Matcher matcher = Pattern.compile("[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}").matcher(fileName);
- if (matcher.find()) {
- String timeString = matcher.group(0);
- return BackupNameTimeFormatter.timeStringToLocalDateTime(timeString);
- }
- return null;
- }
-
- private String getBackupName(String backupFileName) {
- try {
- if (backupFileName.matches(BackupFilesystemUtil.getBackupFileNamePrefix() + ".+\\.zip"))
- return backupFileName.substring(BackupFilesystemUtil.getBackupFileNamePrefix().length(), backupFileName.length() - 4);
- } catch (IndexOutOfBoundsException ignored) {
- }
- return backupFileName;
- }
-
-}