mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-26 11:08:08 +01:00
Backup DB is now closed if backup fails due to exception
This commit is contained in:
parent
1e75a665b9
commit
4291a94cc6
@ -30,17 +30,23 @@ public class ManageUtils {
|
||||
* @param copyFromDB Database you want to backup.
|
||||
*/
|
||||
public static void backup(String dbName, Database copyFromDB) throws DBInitException, SQLException {
|
||||
SQLiteDB backupDB = null;
|
||||
try {
|
||||
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
|
||||
String fileName = dbName + "-backup-" + timeStamp;
|
||||
SQLiteDB backupDB = new SQLiteDB(fileName);
|
||||
backupDB = new SQLiteDB(fileName);
|
||||
Collection<UUID> uuids = ManageUtils.getUUIDS(copyFromDB);
|
||||
if (uuids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
backupDB.init();
|
||||
clearAndCopy(backupDB, copyFromDB);
|
||||
} finally {
|
||||
if (backupDB != null) {
|
||||
backupDB.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the saved UUIDs in a hashset
|
||||
|
Loading…
Reference in New Issue
Block a user