-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Storage: Add backupAddressBook(ReadOnlyAddressBook) #594
Conversation
dca915a
to
c30e829
Compare
8e692f1
to
a95b7df
Compare
a95b7df
to
e02c15c
Compare
v1@yamgent submitted v1 for review. Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level4.git refs/pr/594/1/head:BRANCHNAME where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As spoken, rmb to update https://github.com/se-edu/addressbook-level4/blob/master/docs/DeveloperGuide.adoc#storage-component to update the logic in XmlAddressBookStorage
too.
@@ -77,6 +77,10 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) th | |||
addressBookStorage.saveAddressBook(addressBook, filePath); | |||
} | |||
|
|||
@Override | |||
public void backupAddressBook(ReadOnlyAddressBook addressBook) throws IOException { | |||
saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath() + "-backup.xml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be calling addressBookStorage#backupAddressBook(ReadOnlyAddressBook)
instead :P
9229461
to
9356bf3
Compare
v2@yamgent submitted v2 for review. (📚 Archive) (📈 Interdiff between v1 and v2) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level4.git refs/pr/594/2/head:BRANCHNAME where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
@yamgent this PR is failing 1 test :< |
875c904
to
5beb949
Compare
5beb949
to
dea2619
Compare
v3@yamgent submitted v3 for review. (📚 Archive) (📈 Interdiff between v2 and v3) (📈 Range-Diff between v2 and v3) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level4.git refs/pr/594/3/head:BRANCHNAME where |
Changelog:
addressbook-level4/src/main/java/seedu/address/storage/XmlAddressBookStorage.java Line 66 in dea2619
|
@@ -60,6 +61,11 @@ public Path getAddressBookFilePath() { | |||
} | |||
} | |||
|
|||
@Override | |||
public void backupAddressBook(ReadOnlyAddressBook addressBook) throws IOException { | |||
saveAddressBook(addressBook, Paths.get(filePath.toString() + ".backup")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether the backup Path should be stored in a private final field, to be assigned in the constructor.
This is so that we don't have to call Paths.get whenever this method is called.
dea2619
to
ff7373c
Compare
v4@yamgent submitted v4 for review. (📚 Archive) (📈 Interdiff between v3 and v4) (📈 Range-Diff between v3 and v4) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level4.git refs/pr/594/4/head:BRANCHNAME where |
|
||
public XmlAddressBookStorage(Path filePath) { | ||
this.filePath = filePath; | ||
this.backupFilePath = Paths.get(filePath.toString() + ".backup"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't use this.
here, my bad.
Storage saves to a single file path. Users may want to do a backup of the address book in a different location. Let's add Storage#backupAddressBook(ReadOnlyAddressBook).
ff7373c
to
931a592
Compare
v5@yamgent submitted v5 for review. (📚 Archive) (📈 Interdiff between v4 and v5) (📈 Range-Diff between v4 and v5) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level4.git refs/pr/594/5/head:BRANCHNAME where |
Part of #784. Rebased, fixed the compilation error.
Proposed commit message:
Note: This PR is used as an example for future developers. Do not merge!