diff options
author | Keuin <[email protected]> | 2021-01-23 14:10:32 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2021-01-23 14:10:32 +0800 |
commit | 4a1d885afa7217b47d6183488c3dc6537cef05b6 (patch) | |
tree | 1b499db6b834cb0709029e30c0d52c0ddf200ffa /src/main/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializer.java | |
parent | 4ac575330130ac4e1b4b35386ffc0aacd431a5a4 (diff) |
Version 1.4.6 (preview): added metadata for incremental backup (need integrated test and display implementation)
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializer.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializer.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializer.java b/src/main/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializer.java index f45d4d0..f663f20 100644 --- a/src/main/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializer.java +++ b/src/main/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializer.java @@ -5,14 +5,20 @@ import java.util.Objects; /** * Serialize and deserialize ObjectCollection from/to the disk file. + * Now we want to save additional metadata in incremental backups. So the serializer on pure ObjectCollection is depreciated. */ public class ObjectCollectionSerializer { - public static ObjectCollection fromFile(File file) throws IOException { + + /** + * This doesn't work with the latest format. Use IncBackupInfoSerializer instead. + */ + @Deprecated + public static ObjectCollection2 fromFile(File file) throws IOException { Objects.requireNonNull(file); - ObjectCollection collection; + ObjectCollection2 collection; try (FileInputStream fileInputStream = new FileInputStream(file)) { try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) { - collection = (ObjectCollection) objectInputStream.readObject(); + collection = (ObjectCollection2) objectInputStream.readObject(); } catch (ClassNotFoundException ignored) { // this should not happen return null; @@ -21,7 +27,10 @@ public class ObjectCollectionSerializer { return collection; } - public static void toFile(ObjectCollection collection, File file) throws IOException { + /** + * Only used for testing backward-compatibility with legacy backups. + */ + public static void toFile(ObjectCollection2 collection, File file) throws IOException { Objects.requireNonNull(collection); Objects.requireNonNull(file); try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { |