diff --git a/wox.core/resource/resource.go b/wox.core/resource/resource.go index 9e4b3954..ec26e975 100644 --- a/wox.core/resource/resource.go +++ b/wox.core/resource/resource.go @@ -35,26 +35,60 @@ var embedThemes = []string{} func Extract(ctx context.Context) error { start := util.GetSystemTimestamp() - extractHostErr := extractFiles(ctx, HostFS, util.GetLocation().GetHostDirectory(), "hosts", false) + + // hosts + hostDirectory := util.GetLocation().GetHostDirectory() + if util.IsDirExists(hostDirectory) { + rmErr := os.RemoveAll(hostDirectory) + if rmErr != nil { + return rmErr + } + } + extractHostErr := extractFiles(ctx, HostFS, hostDirectory, "hosts", false) if extractHostErr != nil { return extractHostErr } - flutterErr := extractFiles(ctx, UIFS, util.GetLocation().GetUIDirectory(), "ui/flutter", true) + // ui + uiDiretory := util.GetLocation().GetUIDirectory() + if util.IsDirExists(uiDiretory) { + rmErr := os.RemoveAll(uiDiretory) + if rmErr != nil { + return rmErr + } + } + flutterErr := extractFiles(ctx, UIFS, uiDiretory, "ui/flutter", true) if flutterErr != nil { return flutterErr } - othersErr := extractFiles(ctx, OthersFS, util.GetLocation().GetOthersDirectory(), "others", false) + // others + othersDirectory := util.GetLocation().GetOthersDirectory() + if util.IsDirExists(othersDirectory) { + rmErr := os.RemoveAll(othersDirectory) + if rmErr != nil { + return rmErr + } + } + othersErr := extractFiles(ctx, OthersFS, othersDirectory, "others", false) if othersErr != nil { return othersErr } - scriptPluginTemplatesErr := extractFiles(ctx, ScriptPluginTemplatesFS, util.GetLocation().GetScriptPluginTemplatesDirectory(), "script_plugin_templates", false) + // script_plugin_templates + scriptPluginTemplatesDirectory := util.GetLocation().GetScriptPluginTemplatesDirectory() + if util.IsDirExists(scriptPluginTemplatesDirectory) { + rmErr := os.RemoveAll(scriptPluginTemplatesDirectory) + if rmErr != nil { + return rmErr + } + } + scriptPluginTemplatesErr := extractFiles(ctx, ScriptPluginTemplatesFS, scriptPluginTemplatesDirectory, "script_plugin_templates", false) if scriptPluginTemplatesErr != nil { return scriptPluginTemplatesErr } + // themes themeErr := parseThemes(ctx) if themeErr != nil { return themeErr diff --git a/wox.core/ui/manager.go b/wox.core/ui/manager.go index a76db77c..bde70284 100644 --- a/wox.core/ui/manager.go +++ b/wox.core/ui/manager.go @@ -295,7 +295,7 @@ func (m *Manager) UpdateServerPort(port int) { func (m *Manager) StartUIApp(ctx context.Context) error { var appPath = util.GetLocation().GetUIAppPath() if fileInfo, statErr := os.Stat(appPath); os.IsNotExist(statErr) { - logger.Info(ctx, "UI app not exist") + logger.Info(ctx, "UI app not exist: "+appPath) return errors.New("UI app not exist") } else { if !util.IsFileExecAny(fileInfo.Mode()) {