mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (IO/NIO mixing; typos)
GitOrigin-RevId: 52eb16a0cd86288716c2e591b4442ff75c996867
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f03ca2caba
commit
992fb746a9
@@ -38,8 +38,8 @@ public class StartupActionScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void executeActionScript(@NotNull Path scriptFile, @NotNull Path oldTarget, @NotNull File newTarget) throws IOException {
|
||||
List<ActionCommand> commands = loadActionScript(scriptFile);
|
||||
public static synchronized void executeActionScript(@NotNull File scriptFile, @NotNull File oldTarget, @NotNull File newTarget) throws IOException {
|
||||
List<ActionCommand> commands = loadActionScript(scriptFile.toPath());
|
||||
for (ActionCommand command : commands) {
|
||||
ActionCommand toExecute = mapPaths(command, oldTarget, newTarget);
|
||||
if (toExecute != null) {
|
||||
@@ -89,11 +89,11 @@ public class StartupActionScriptManager {
|
||||
if (data instanceof ActionCommand[]) {
|
||||
return new ArrayList<>(Arrays.asList((ActionCommand[])data));
|
||||
}
|
||||
else if (data instanceof List && ((List)data).size() == 0) {
|
||||
else if (data instanceof List && ((List<?>)data).size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
else {
|
||||
throw new IOException("Unexpected object: " + data + "/" + data.getClass());
|
||||
throw new IOException("An unexpected object: " + data + "/" + data.getClass());
|
||||
}
|
||||
}
|
||||
catch (ReflectiveOperationException e) {
|
||||
@@ -114,7 +114,7 @@ public class StartupActionScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static ActionCommand mapPaths(ActionCommand command, Path oldTarget, File newTarget) {
|
||||
private static ActionCommand mapPaths(ActionCommand command, File oldTarget, File newTarget) {
|
||||
if (command instanceof CopyCommand) {
|
||||
File destination = mapPath(((CopyCommand)command).myDestination, oldTarget, newTarget);
|
||||
if (destination != null) {
|
||||
@@ -137,8 +137,8 @@ public class StartupActionScriptManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static File mapPath(String path, Path oldTarget, File newTarget) {
|
||||
String oldTargetPath = oldTarget.toString();
|
||||
private static File mapPath(String path, File oldTarget, File newTarget) {
|
||||
String oldTargetPath = oldTarget.getPath();
|
||||
if (path.startsWith(oldTargetPath)) {
|
||||
if (path.length() == oldTargetPath.length()) {
|
||||
return newTarget;
|
||||
@@ -177,7 +177,7 @@ public class StartupActionScriptManager {
|
||||
|
||||
File destDir = destination.getParentFile();
|
||||
if (!(destDir.isDirectory() || destDir.mkdirs())) {
|
||||
throw new IOException("Cannot create directory: " + destDir);
|
||||
throw new IOException("Cannot create a directory: " + destDir);
|
||||
}
|
||||
|
||||
FileUtilRt.copy(source, destination);
|
||||
@@ -215,7 +215,7 @@ public class StartupActionScriptManager {
|
||||
}
|
||||
|
||||
if (!(destination.isDirectory() || destination.mkdirs())) {
|
||||
throw new IOException("Cannot create directory: " + destination);
|
||||
throw new IOException("Cannot create a directory: " + destination);
|
||||
}
|
||||
|
||||
ZipUtil.extract(source, destination, myFilenameFilter);
|
||||
|
||||
@@ -119,8 +119,7 @@ public class PluginInstaller {
|
||||
commands.add(new StartupActionScriptManager.CopyCommand(sourceFile, new File(pluginsPath, sourceFile.getName())));
|
||||
}
|
||||
else {
|
||||
commands
|
||||
.add(new StartupActionScriptManager.DeleteCommand(new File(pluginsPath, rootEntryName(sourceFile)))); // drops stale directory
|
||||
commands.add(new StartupActionScriptManager.DeleteCommand(new File(pluginsPath, rootEntryName(sourceFile)))); // drops stale directory
|
||||
commands.add(new StartupActionScriptManager.UnzipCommand(sourceFile, new File(pluginsPath)));
|
||||
}
|
||||
|
||||
|
||||
@@ -412,7 +412,7 @@ public final class ConfigImportHelper {
|
||||
Path script = oldSystemDir.resolve(PLUGINS + '/' + StartupActionScriptManager.ACTION_SCRIPT_FILE); // PathManager#getPluginTempPath
|
||||
if (Files.isRegularFile(script)) {
|
||||
File newPluginsDir = new File(PathManager.getPluginsPath());
|
||||
StartupActionScriptManager.executeActionScript(script, oldPluginsDir, newPluginsDir);
|
||||
StartupActionScriptManager.executeActionScript(script.toFile(), oldPluginsDir.toFile(), newPluginsDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ class StartupActionScriptManagerTest : BareTestFixtureTestCase() {
|
||||
StartupActionScriptManager.CopyCommand(copySource, copyDestinationInOld),
|
||||
StartupActionScriptManager.UnzipCommand(unzipSource, oldTarget),
|
||||
StartupActionScriptManager.DeleteCommand(deleteInOld)))
|
||||
StartupActionScriptManager.executeActionScript(scriptFile, oldTarget.toPath(), newTarget)
|
||||
StartupActionScriptManager.executeActionScript(scriptFile.toFile(), oldTarget, newTarget)
|
||||
|
||||
assertFalse(copyDestinationInOld.exists())
|
||||
assertTrue(copyDestinationInNew.exists())
|
||||
|
||||
Reference in New Issue
Block a user