fix: remove debug logs and fix cache clearing

This commit is contained in:
2025-06-14 15:05:18 +03:00
parent bece64c132
commit 661d79ce24
6 changed files with 52 additions and 29 deletions

View File

@ -11,7 +11,7 @@
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> <text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
<text x="33.5" y="14">coverage</text> <text x="33.5" y="14">coverage</text>
<text x="86" y="15" fill="#010101" fill-opacity=".3">17.6%</text> <text x="86" y="15" fill="#010101" fill-opacity=".3">17.5%</text>
<text x="86" y="14">17.6%</text> <text x="86" y="14">17.5%</text>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 926 B

After

Width:  |  Height:  |  Size: 926 B

30
fix.go
View File

@ -20,6 +20,7 @@
package main package main
import ( import (
"io/fs"
"log/slog" "log/slog"
"os" "os"
"path/filepath" "path/filepath"
@ -57,7 +58,6 @@ func FixCmd() *cli.Command {
paths := cfg.GetPaths() paths := cfg.GetPaths()
slog.Info(gotext.Get("Clearing cache directory")) slog.Info(gotext.Get("Clearing cache directory"))
// Remove all nested directories of paths.CacheDir
dir, err := os.Open(paths.CacheDir) dir, err := os.Open(paths.CacheDir)
if err != nil { if err != nil {
@ -71,7 +71,13 @@ func FixCmd() *cli.Command {
} }
for _, entry := range entries { for _, entry := range entries {
err = os.RemoveAll(filepath.Join(paths.CacheDir, entry)) fullPath := filepath.Join(paths.CacheDir, entry)
if err := makeWritableRecursive(fullPath); err != nil {
slog.Debug("Failed to make path writable", "path", fullPath, "error", err)
}
err = os.RemoveAll(fullPath)
if err != nil { if err != nil {
return cliutils.FormatCliExit(gotext.Get("Unable to remove cache item (%s)", entry), err) return cliutils.FormatCliExit(gotext.Get("Unable to remove cache item (%s)", entry), err)
} }
@ -101,3 +107,23 @@ func FixCmd() *cli.Command {
}, },
} }
} }
func makeWritableRecursive(path string) error {
return filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
info, err := d.Info()
if err != nil {
return err
}
newMode := info.Mode() | 0o200
if d.IsDir() {
newMode |= 0o100
}
return os.Chmod(path, newMode)
})
}

View File

@ -200,7 +200,6 @@ func buildPkgMetadata(
preferedContents *[]string, preferedContents *[]string,
) (*nfpm.Info, error) { ) (*nfpm.Info, error) {
pkgInfo := getBasePkgInfo(vars, input) pkgInfo := getBasePkgInfo(vars, input)
slog.Warn("vars.Description", "vars.Description", vars.Description, "vars.Description.Resolved", vars.Description.Resolved())
pkgInfo.Description = vars.Description.Resolved() pkgInfo.Description = vars.Description.Resolved()
pkgInfo.Platform = "linux" pkgInfo.Platform = "linux"
pkgInfo.Homepage = vars.Homepage.Resolved() pkgInfo.Homepage = vars.Homepage.Resolved()

View File

@ -20,7 +20,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"log/slog" "log/slog"
"runtime/debug"
"github.com/leonelquinteros/gotext" "github.com/leonelquinteros/gotext"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
@ -45,12 +44,10 @@ func HandleExitCoder(err error) {
slog.Error(err.Error()) slog.Error(err.Error())
} }
} }
debug.PrintStack()
cli.OsExiter(exitErr.ExitCode()) cli.OsExiter(exitErr.ExitCode())
return return
} }
debug.PrintStack()
slog.Error(err.Error()) slog.Error(err.Error())
cli.OsExiter(1) cli.OsExiter(1)
} }

View File

@ -58,11 +58,11 @@ msgstr ""
msgid "Done" msgid "Done"
msgstr "" msgstr ""
#: fix.go:38 #: fix.go:39
msgid "Attempt to fix problems with ALR" msgid "Attempt to fix problems with ALR"
msgstr "" msgstr ""
#: fix.go:59 #: fix.go:60
msgid "Clearing cache directory" msgid "Clearing cache directory"
msgstr "" msgstr ""
@ -74,15 +74,15 @@ msgstr ""
msgid "Unable to read cache directory contents" msgid "Unable to read cache directory contents"
msgstr "" msgstr ""
#: fix.go:76 #: fix.go:82
msgid "Unable to remove cache item (%s)" msgid "Unable to remove cache item (%s)"
msgstr "" msgstr ""
#: fix.go:80 #: fix.go:86
msgid "Rebuilding cache" msgid "Rebuilding cache"
msgstr "" msgstr ""
#: fix.go:84 #: fix.go:90
msgid "Unable to create new cache directory" msgid "Unable to create new cache directory"
msgstr "" msgstr ""
@ -224,15 +224,15 @@ msgstr ""
msgid "Building package metadata" msgid "Building package metadata"
msgstr "" msgstr ""
#: internal/build/script_executor.go:276 #: internal/build/script_executor.go:275
msgid "Executing prepare()" msgid "Executing prepare()"
msgstr "" msgstr ""
#: internal/build/script_executor.go:285 #: internal/build/script_executor.go:284
msgid "Executing build()" msgid "Executing build()"
msgstr "" msgstr ""
#: internal/build/script_executor.go:314 internal/build/script_executor.go:334 #: internal/build/script_executor.go:313 internal/build/script_executor.go:333
msgid "Executing %s()" msgid "Executing %s()"
msgstr "" msgstr ""
@ -336,7 +336,7 @@ msgstr ""
msgid "OPTIONS" msgid "OPTIONS"
msgstr "" msgstr ""
#: internal/cliutils/utils.go:72 #: internal/cliutils/utils.go:69
msgid "" msgid ""
"This command is deprecated and would be removed in the future, use \"%s\" " "This command is deprecated and would be removed in the future, use \"%s\" "
"instead!" "instead!"

View File

@ -65,11 +65,11 @@ msgstr "Ошибка при перемещении пакета"
msgid "Done" msgid "Done"
msgstr "Сделано" msgstr "Сделано"
#: fix.go:38 #: fix.go:39
msgid "Attempt to fix problems with ALR" msgid "Attempt to fix problems with ALR"
msgstr "Попытка устранить проблемы с ALR" msgstr "Попытка устранить проблемы с ALR"
#: fix.go:59 #: fix.go:60
msgid "Clearing cache directory" msgid "Clearing cache directory"
msgstr "Очистка каталога кэша" msgstr "Очистка каталога кэша"
@ -81,15 +81,15 @@ msgstr "Невозможно открыть каталог кэша"
msgid "Unable to read cache directory contents" msgid "Unable to read cache directory contents"
msgstr "Невозможно прочитать содержимое каталога кэша" msgstr "Невозможно прочитать содержимое каталога кэша"
#: fix.go:76 #: fix.go:82
msgid "Unable to remove cache item (%s)" msgid "Unable to remove cache item (%s)"
msgstr "Невозможно удалить элемент кэша (%s)" msgstr "Невозможно удалить элемент кэша (%s)"
#: fix.go:80 #: fix.go:86
msgid "Rebuilding cache" msgid "Rebuilding cache"
msgstr "Восстановление кэша" msgstr "Восстановление кэша"
#: fix.go:84 #: fix.go:90
msgid "Unable to create new cache directory" msgid "Unable to create new cache directory"
msgstr "Не удалось создать новый каталог кэша" msgstr "Не удалось создать новый каталог кэша"
@ -235,15 +235,15 @@ msgstr ""
msgid "Building package metadata" msgid "Building package metadata"
msgstr "Сборка метаданных пакета" msgstr "Сборка метаданных пакета"
#: internal/build/script_executor.go:276 #: internal/build/script_executor.go:275
msgid "Executing prepare()" msgid "Executing prepare()"
msgstr "Выполнение prepare()" msgstr "Выполнение prepare()"
#: internal/build/script_executor.go:285 #: internal/build/script_executor.go:284
msgid "Executing build()" msgid "Executing build()"
msgstr "Выполнение build()" msgstr "Выполнение build()"
#: internal/build/script_executor.go:314 internal/build/script_executor.go:334 #: internal/build/script_executor.go:313 internal/build/script_executor.go:333
msgid "Executing %s()" msgid "Executing %s()"
msgstr "Выполнение %s()" msgstr "Выполнение %s()"
@ -347,7 +347,7 @@ msgstr "КАТЕГОРИЯ"
msgid "OPTIONS" msgid "OPTIONS"
msgstr "ПАРАМЕТРЫ" msgstr "ПАРАМЕТРЫ"
#: internal/cliutils/utils.go:72 #: internal/cliutils/utils.go:69
msgid "" msgid ""
"This command is deprecated and would be removed in the future, use \"%s\" " "This command is deprecated and would be removed in the future, use \"%s\" "
"instead!" "instead!"
@ -569,6 +569,10 @@ msgstr "Ошибка при проверке обновлений"
msgid "There is nothing to do." msgid "There is nothing to do."
msgstr "Здесь нечего делать." msgstr "Здесь нечего делать."
#, fuzzy
#~ msgid "Failed to clear contents of cache directory"
#~ msgstr "Не удалось создать каталог кэша репозитория"
#~ msgid "Error iterating over packages" #~ msgid "Error iterating over packages"
#~ msgstr "Ошибка при переборе пакетов" #~ msgstr "Ошибка при переборе пакетов"
@ -587,9 +591,6 @@ msgstr "Здесь нечего делать."
#~ msgid "Unable to create config directory" #~ msgid "Unable to create config directory"
#~ msgstr "Не удалось создать каталог конфигурации ALR" #~ msgstr "Не удалось создать каталог конфигурации ALR"
#~ msgid "Unable to create repo cache directory"
#~ msgstr "Не удалось создать каталог кэша репозитория"
#~ msgid "Unable to create package cache directory" #~ msgid "Unable to create package cache directory"
#~ msgstr "Не удалось создать каталог кэша пакетов" #~ msgstr "Не удалось создать каталог кэша пакетов"