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,16 +30,22 @@ public class ManageUtils {
|
|||||||
* @param copyFromDB Database you want to backup.
|
* @param copyFromDB Database you want to backup.
|
||||||
*/
|
*/
|
||||||
public static void backup(String dbName, Database copyFromDB) throws DBInitException, SQLException {
|
public static void backup(String dbName, Database copyFromDB) throws DBInitException, SQLException {
|
||||||
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
|
SQLiteDB backupDB = null;
|
||||||
String fileName = dbName + "-backup-" + timeStamp;
|
try {
|
||||||
SQLiteDB backupDB = new SQLiteDB(fileName);
|
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
|
||||||
Collection<UUID> uuids = ManageUtils.getUUIDS(copyFromDB);
|
String fileName = dbName + "-backup-" + timeStamp;
|
||||||
if (uuids.isEmpty()) {
|
backupDB = new SQLiteDB(fileName);
|
||||||
return;
|
Collection<UUID> uuids = ManageUtils.getUUIDS(copyFromDB);
|
||||||
|
if (uuids.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
backupDB.init();
|
||||||
|
clearAndCopy(backupDB, copyFromDB);
|
||||||
|
} finally {
|
||||||
|
if (backupDB != null) {
|
||||||
|
backupDB.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
backupDB.init();
|
|
||||||
clearAndCopy(backupDB, copyFromDB);
|
|
||||||
backupDB.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user