mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 16:14:26 +08:00
Disabled manage move h2<->mysql
Move between h2 and mysql is buggy, see #1111 for more details
This commit is contained in:
parent
ae81afb372
commit
c292d441a0
@ -77,27 +77,33 @@ public class ManageMoveCommand extends CommandNode {
|
||||
Verify.isTrue(args.length >= 2,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 2, Arrays.toString(this.getArguments()))));
|
||||
|
||||
String fromDB = args[0].toLowerCase();
|
||||
boolean isCorrectDB = DBType.exists(fromDB);
|
||||
Verify.isTrue(isCorrectDB,
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, fromDB)));
|
||||
DBType fromDB = DBType.getForName(args[0])
|
||||
.orElseThrow(() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, args[0])));
|
||||
|
||||
String toDB = args[1].toLowerCase();
|
||||
isCorrectDB = DBType.exists(toDB);
|
||||
Verify.isTrue(isCorrectDB,
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, toDB)));
|
||||
DBType toDB = DBType.getForName(args[1])
|
||||
.orElseThrow(() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, args[1])));
|
||||
|
||||
Verify.isFalse(fromDB.equalsIgnoreCase(toDB),
|
||||
Verify.isFalse(fromDB == toDB,
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_SAME_DB)));
|
||||
|
||||
if (!Verify.contains("-a", args)) {
|
||||
sender.sendMessage(locale.getString(ManageLang.CONFIRMATION, locale.getString(ManageLang.CONFIRM_OVERWRITE, toDB)));
|
||||
sender.sendMessage(locale.getString(ManageLang.CONFIRMATION, locale.getString(ManageLang.CONFIRM_OVERWRITE, toDB.getConfigName())));
|
||||
return;
|
||||
}
|
||||
|
||||
// Temporarily disabled due to issues
|
||||
boolean transferH2 = fromDB == DBType.H2 || toDB == DBType.H2;
|
||||
boolean transferMySQL = fromDB == DBType.MYSQL || toDB == DBType.MYSQL;
|
||||
|
||||
if (transferH2 && transferMySQL) {
|
||||
sender.sendMessage("§cDirect transfers between H2 and MySQL are temporarily disabled due to a bug: See the issue link for workaround");
|
||||
sender.sendLink("Link to Github Issue", "https://github.com/plan-player-analytics/Plan/issues/1111");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final Database fromDatabase = dbSystem.getActiveDatabaseByName(fromDB);
|
||||
final Database toDatabase = dbSystem.getActiveDatabaseByName(toDB);
|
||||
final Database fromDatabase = dbSystem.getActiveDatabaseByType(fromDB);
|
||||
final Database toDatabase = dbSystem.getActiveDatabaseByType(toDB);
|
||||
fromDatabase.init();
|
||||
toDatabase.init();
|
||||
|
||||
|
@ -81,7 +81,6 @@ public enum DBType {
|
||||
return Optional.of(dbType);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.system.database;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.H2DB;
|
||||
import com.djrapitops.plan.db.SQLiteDB;
|
||||
@ -27,7 +28,6 @@ import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.HashSet;
|
||||
@ -69,13 +69,18 @@ public abstract class DBSystem implements SubSystem {
|
||||
}
|
||||
|
||||
public Database getActiveDatabaseByName(String dbName) {
|
||||
return DBType.getForName(dbName)
|
||||
.map(this::getActiveDatabaseByType)
|
||||
.orElseThrow(() -> new IllegalArgumentException(locale.getString(PluginLang.ENABLE_FAIL_WRONG_DB, dbName)));
|
||||
}
|
||||
|
||||
public Database getActiveDatabaseByType(DBType type) {
|
||||
for (Database database : getDatabases()) {
|
||||
String dbConfigName = database.getType().getConfigName();
|
||||
if (Verify.equalsIgnoreCase(dbName, dbConfigName)) {
|
||||
if (database.getType() == type) {
|
||||
return database;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(locale.getString(PluginLang.ENABLE_FAIL_WRONG_DB, dbName));
|
||||
throw new IllegalArgumentException(locale.getString(PluginLang.ENABLE_FAIL_WRONG_DB, type != null ? type.getName() : "null"));
|
||||
}
|
||||
|
||||
public Set<Database> getDatabases() {
|
||||
|
Loading…
Reference in New Issue
Block a user