Skip to content

Commit 7513e19

Browse files
author
Bytekeeper
committed
Fixed backup folder not being created if it doesn't exist.
1 parent 4ea1f30 commit 7513e19

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/org/stt/config/BackupConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class BackupConfig implements ConfigurationContainer {
44
private int backupInterval = 7;
55
private int backupRetentionCount = 0;
6-
private PathSetting backupLocation = new PathSetting("$HOME$");
6+
private PathSetting backupLocation = new PathSetting("$HOME$/.stt/backups");
77
private PathSetting itemLogFile = new PathSetting("$HOME$/.stt/itemlog");
88

99
public int getBackupInterval() {

src/main/java/org/stt/persistence/BackupCreator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ public void start() throws IOException {
6868

6969
File backupLocation = backupConfig.getBackupLocation().file(homePath);
7070

71+
if (!backupLocation.exists()) {
72+
boolean mkdirs = backupLocation.mkdirs();
73+
if (!mkdirs) {
74+
throw new IOException("Couldn't create backup folder: " + backupLocation.getAbsolutePath());
75+
}
76+
}
77+
7178
if (!backupLocation.canWrite()) {
7279
throw new IOException("cannot persist to "
7380
+ backupLocation.getAbsolutePath());

0 commit comments

Comments
 (0)