mirror of https://github.com/halo-dev/halo
fix: plugin startup failed issue on Windows system (#3925)
#### What type of PR is this? /kind bug /area core /milestone 2.6.x #### What this PR does / why we need it: 修复在 Windows 系统无法启动插件的问题 how to test it? 1. 使用 windows 系统环境测试插件开发模式和生产模式是否正常工作 2. 测试从 2.0.0 版本安装插件然后切换到此 PR 后插件不会出现找不到文件的错误 3. 测试插件安装和升级是否正常 #### Which issue(s) this PR fixes: Fixes #3906 #### Does this PR introduce a user-facing change? ```release-note 修复在 Windows 系统无法启动插件的问题 ```pull/3954/head
parent
017bb55521
commit
90723f5382
|
@ -577,7 +577,6 @@ public class PluginReconciler implements Reconciler<Request> {
|
||||||
return pluginPath.toString();
|
return pluginPath.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns absolute plugin path.
|
* Returns absolute plugin path.
|
||||||
* if plugin path is absolute, use it directly in development mode.
|
* if plugin path is absolute, use it directly in development mode.
|
||||||
|
@ -629,7 +628,11 @@ public class PluginReconciler implements Reconciler<Request> {
|
||||||
if (StringUtils.isBlank(pathString)) {
|
if (StringUtils.isBlank(pathString)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Paths.get(URI.create(pathString).getPath());
|
String processedPathString = pathString;
|
||||||
|
if (processedPathString.startsWith("file:")) {
|
||||||
|
processedPathString = processedPathString.substring(7);
|
||||||
|
}
|
||||||
|
return Paths.get(processedPathString);
|
||||||
}
|
}
|
||||||
|
|
||||||
URI toUri(String pathString) {
|
URI toUri(String pathString) {
|
||||||
|
|
|
@ -468,6 +468,14 @@ class PluginReconcilerTest {
|
||||||
Path path = pluginReconciler.toPath("file:///path/to/file.txt");
|
Path path = pluginReconciler.toPath("file:///path/to/file.txt");
|
||||||
assertThat(path).isNotNull();
|
assertThat(path).isNotNull();
|
||||||
assertThat(path.toString()).isEqualTo("/path/to/file.txt");
|
assertThat(path.toString()).isEqualTo("/path/to/file.txt");
|
||||||
|
|
||||||
|
assertThat(pluginReconciler.toPath("C:\\Users\\faker\\halo\\plugins").toString())
|
||||||
|
.isEqualTo("C:\\Users\\faker\\halo\\plugins");
|
||||||
|
assertThat(pluginReconciler.toPath("C:/Users/faker/halo/plugins").toString())
|
||||||
|
.isEqualTo("C:/Users/faker/halo/plugins");
|
||||||
|
Path windowsPath = Paths.get("C:/Users/username/Documents/file.txt");
|
||||||
|
assertThat(pluginReconciler.toPath("file://C:/Users/username/Documents/file.txt"))
|
||||||
|
.isEqualTo(windowsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue