mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
Fixed concurrency issues with backup related commands
This commit is contained in:
parent
e1bef920e7
commit
6fbd8ced60
@ -43,6 +43,7 @@ import com.djrapitops.plugin.utilities.Verify;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* This command is used to backup a database to a .db file.
|
||||
@ -136,9 +137,12 @@ public class ManageBackupCommand extends CommandNode {
|
||||
String fileName = dbName + "-backup-" + timeStamp;
|
||||
backupDB = sqliteFactory.usingFileCalled(fileName);
|
||||
backupDB.init();
|
||||
backupDB.executeTransaction(new BackupCopyTransaction(copyFromDB, backupDB));
|
||||
} catch (DBException e) {
|
||||
backupDB.executeTransaction(new BackupCopyTransaction(copyFromDB, backupDB)).get();
|
||||
} catch (DBException | ExecutionException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
} catch (InterruptedException e) {
|
||||
backupDB.close();
|
||||
Thread.currentThread().interrupt();
|
||||
} finally {
|
||||
if (backupDB != null) {
|
||||
backupDB.close();
|
||||
|
@ -112,7 +112,7 @@ public class ManageMoveCommand extends CommandNode {
|
||||
try {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
toDatabase.executeTransaction(new BackupCopyTransaction(fromDatabase, toDatabase));
|
||||
toDatabase.executeTransaction(new BackupCopyTransaction(fromDatabase, toDatabase)).get();
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
|
||||
@ -120,6 +120,8 @@ public class ManageMoveCommand extends CommandNode {
|
||||
if (movingToCurrentDB) {
|
||||
sender.sendMessage(locale.getString(ManageLang.HOTSWAP_REMINDER, toDatabase.getType().getConfigName()));
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
|
@ -124,9 +124,11 @@ public class ManageRestoreCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
database.executeTransaction(new BackupCopyTransaction(backupDB, database));
|
||||
database.executeTransaction(new BackupCopyTransaction(backupDB, database)).get();
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
|
Loading…
Reference in New Issue
Block a user