fix: unable to use plugin development mode on Windows systems (#4480)

#### What type of PR is this?
/kind bug
/area core
/milestone 2.9.x

#### What this PR does / why we need it:
修复 Windows 系统上的插件路径问题

how to test it?
1. 在 windows 系统上使用插件生成模式初始化 halo 插件可以正常运行,测试上传插件 jar 升级可以正常运行
2. 测试 windows 系统上使用插件开发模式可以正确运行插件

#### Which issue(s) this PR fixes:
Fixes #4466 

#### Does this PR introduce a user-facing change?
```release-note
修复 Windows 系统上的插件路径问题
```
pull/4482/head
guqing 2023-08-25 23:16:12 +08:00 committed by GitHub
parent e5df695f9d
commit 2aeeb3e463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -55,6 +55,7 @@ import run.halo.app.extension.controller.Reconciler;
import run.halo.app.extension.controller.Reconciler.Request;
import run.halo.app.infra.Condition;
import run.halo.app.infra.ConditionStatus;
import run.halo.app.infra.utils.FileUtils;
import run.halo.app.infra.utils.JsonUtils;
import run.halo.app.infra.utils.PathUtils;
import run.halo.app.infra.utils.YamlUnstructuredLoader;
@ -391,9 +392,11 @@ public class PluginReconciler implements Reconciler<Request> {
return null;
});
} catch (Exception e) {
haloPluginManager.stopPlugin(name);
PluginWrapper pluginWrapper = haloPluginManager.getPlugin(name);
pluginWrapper.setPluginState(PluginState.FAILED);
if (pluginWrapper != null) {
haloPluginManager.stopPlugin(name);
pluginWrapper.setPluginState(PluginState.FAILED);
}
throw e;
}
}
@ -614,7 +617,11 @@ public class PluginReconciler implements Reconciler<Request> {
}
return pluginPath.toString();
}
return PathUtils.combinePath(pluginsRoot.toString(), pluginPath.toString());
var result = pluginsRoot.resolve(pluginPath);
if (!isDevelopmentMode(name)) {
FileUtils.checkDirectoryTraversal(pluginsRoot, result);
}
return result.toString();
}
boolean shouldDeleteFile(String newPluginPath, URI oldPluginLocation) {