mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-20 11:42:50 +02: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.
|
||||
*/
|
||||
public static void backup(String dbName, Database copyFromDB) throws DBInitException, SQLException {
|
||||
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
|
||||
String fileName = dbName + "-backup-" + timeStamp;
|
||||
SQLiteDB backupDB = new SQLiteDB(fileName);
|
||||
Collection<UUID> uuids = ManageUtils.getUUIDS(copyFromDB);
|
||||
if (uuids.isEmpty()) {
|
||||
return;
|
||||
SQLiteDB backupDB = null;
|
||||
try {
|
||||
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
|
||||
String fileName = dbName + "-backup-" + timeStamp;
|
||||
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();
|
||||
}
|
||||
}
|
||||
backupDB.init();
|
||||
clearAndCopy(backupDB, copyFromDB);
|
||||
backupDB.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user