diff --git a/kernel/bazaar/icon.go b/kernel/bazaar/icon.go index 92af7c44b..96fa69218 100644 --- a/kernel/bazaar/icon.go +++ b/kernel/bazaar/icon.go @@ -159,15 +159,16 @@ func InstalledIcons() (ret []*Icon) { continue } + icon.RepoURL = icon.URL icon.DisallowInstall = disallowInstallBazaarPackage(icon.Package) if bazaarPkg := getBazaarIcon(icon.Name, bazaarIcons); nil != bazaarPkg { icon.DisallowUpdate = disallowInstallBazaarPackage(bazaarPkg.Package) icon.UpdateRequiredMinAppVer = bazaarPkg.MinAppVersion + icon.RepoURL = bazaarPkg.RepoURL } installPath := filepath.Join(util.IconsPath, dirName) icon.Installed = true - icon.RepoURL = icon.URL icon.PreviewURL = "/appearance/icons/" + dirName + "/preview.png" icon.PreviewURLThumb = "/appearance/icons/" + dirName + "/preview.png" icon.IconURL = "/appearance/icons/" + dirName + "/icon.png" diff --git a/kernel/bazaar/plugin.go b/kernel/bazaar/plugin.go index 4f1962749..e61e67791 100644 --- a/kernel/bazaar/plugin.go +++ b/kernel/bazaar/plugin.go @@ -195,15 +195,16 @@ func InstalledPlugins(frontend string) (ret []*Plugin) { continue } + plugin.RepoURL = plugin.URL plugin.DisallowInstall = disallowInstallBazaarPackage(plugin.Package) if bazaarPkg := getBazaarPlugin(plugin.Name, bazaarPlugins); nil != bazaarPkg { plugin.DisallowUpdate = disallowInstallBazaarPackage(bazaarPkg.Package) plugin.UpdateRequiredMinAppVer = bazaarPkg.MinAppVersion + plugin.RepoURL = bazaarPkg.RepoURL } installPath := filepath.Join(util.DataDir, "plugins", dirName) plugin.Installed = true - plugin.RepoURL = plugin.URL plugin.PreviewURL = "/plugins/" + dirName + "/preview.png" plugin.PreviewURLThumb = "/plugins/" + dirName + "/preview.png" plugin.IconURL = "/plugins/" + dirName + "/icon.png" diff --git a/kernel/bazaar/template.go b/kernel/bazaar/template.go index b36de3a04..d77cc0ee5 100644 --- a/kernel/bazaar/template.go +++ b/kernel/bazaar/template.go @@ -160,15 +160,16 @@ func InstalledTemplates() (ret []*Template) { continue } + template.RepoURL = template.URL template.DisallowInstall = disallowInstallBazaarPackage(template.Package) if bazaarPkg := getBazaarTemplate(template.Name, bazaarTemplates); nil != bazaarPkg { template.DisallowUpdate = disallowInstallBazaarPackage(bazaarPkg.Package) template.UpdateRequiredMinAppVer = bazaarPkg.MinAppVersion + template.RepoURL = bazaarPkg.RepoURL } installPath := filepath.Join(util.DataDir, "templates", dirName) template.Installed = true - template.RepoURL = template.URL template.PreviewURL = "/templates/" + dirName + "/preview.png" template.PreviewURLThumb = "/templates/" + dirName + "/preview.png" template.IconURL = "/templates/" + dirName + "/icon.png" diff --git a/kernel/bazaar/theme.go b/kernel/bazaar/theme.go index 083a7573a..e25b85c96 100644 --- a/kernel/bazaar/theme.go +++ b/kernel/bazaar/theme.go @@ -161,15 +161,16 @@ func InstalledThemes() (ret []*Theme) { continue } + theme.RepoURL = theme.URL theme.DisallowInstall = disallowInstallBazaarPackage(theme.Package) if bazaarPkg := getBazaarTheme(theme.Name, bazaarThemes); nil != bazaarPkg { theme.DisallowUpdate = disallowInstallBazaarPackage(bazaarPkg.Package) theme.UpdateRequiredMinAppVer = bazaarPkg.MinAppVersion + theme.RepoURL = bazaarPkg.RepoURL } installPath := filepath.Join(util.ThemesPath, dirName) theme.Installed = true - theme.RepoURL = theme.URL theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png" theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png" theme.IconURL = "/appearance/themes/" + dirName + "/icon.png" diff --git a/kernel/bazaar/widget.go b/kernel/bazaar/widget.go index c8495f5ce..56196fbb4 100644 --- a/kernel/bazaar/widget.go +++ b/kernel/bazaar/widget.go @@ -157,15 +157,16 @@ func InstalledWidgets() (ret []*Widget) { continue } + widget.RepoURL = widget.URL widget.DisallowInstall = disallowInstallBazaarPackage(widget.Package) if bazaarPkg := getBazaarWidget(widget.Name, bazaarWidgets); nil != bazaarPkg { widget.DisallowUpdate = disallowInstallBazaarPackage(bazaarPkg.Package) widget.UpdateRequiredMinAppVer = bazaarPkg.MinAppVersion + widget.RepoURL = bazaarPkg.RepoURL } installPath := filepath.Join(util.DataDir, "widgets", dirName) widget.Installed = true - widget.RepoURL = widget.URL widget.PreviewURL = "/widgets/" + dirName + "/preview.png" widget.PreviewURLThumb = "/widgets/" + dirName + "/preview.png" widget.IconURL = "/widgets/" + dirName + "/icon.png" diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index ebf46513b..5bcf8fe1a 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -177,11 +177,18 @@ func UnusedAttributeViews() (ret []*UnusedItem) { } // 按文件更新时间排序 + modTimes := make([]time.Time, len(ret)) + for i := range ret { + p := filepath.Join(util.DataDir, "storage", "av", ret[i].Item+".json") + if info, statErr := os.Stat(p); nil != statErr { + modTimes[i] = info.ModTime() + } else { + modTimes[i] = time.Time{} + } + } sort.Slice(ret, func(i, j int) bool { - iInfo, iErr := os.Stat(filepath.Join(util.DataDir, "storage", "av", ret[i].Item+".json")) - jInfo, jErr := os.Stat(filepath.Join(util.DataDir, "storage", "av", ret[j].Item+".json")) - if iErr != nil || jErr != nil { - return iInfo.ModTime().After(jInfo.ModTime()) + if !modTimes[i].Equal(modTimes[j]) { + return modTimes[i].After(modTimes[j]) } return ret[i].Item > ret[j].Item }) diff --git a/kernel/sql/database.go b/kernel/sql/database.go index 82f1240c9..cb5336d81 100644 --- a/kernel/sql/database.go +++ b/kernel/sql/database.go @@ -95,12 +95,13 @@ func InitDatabase(forceRebuild bool) (err error) { // 不存在库或者版本不一致都会走到这里 - closeDatabase() + if err = closeDatabase(); nil != err { + logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "close database failed: %s", err) + } + if gulu.File.IsExist(util.DBPath) { if err = removeDatabaseFile(); err != nil { - logging.LogErrorf("remove database file [%s] failed: %s", util.DBPath, err) - util.PushClearProgress() - err = nil + logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "remove database file [%s] failed: %s", util.DBPath, err) } }