From c9fa3d7cd60796bc30df45ef8a6b52edab1b1313 Mon Sep 17 00:00:00 2001 From: foxxorcat <95907542+foxxorcat@users.noreply.github.com> Date: Sun, 8 Sep 2024 10:44:34 +0800 Subject: [PATCH] fix: broken file with local proxy (#7132 close #7112) * fix: local proxy download file damage * fix: temp dir remove --- internal/bootstrap/config.go | 10 ++++++++-- internal/op/fs.go | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/bootstrap/config.go b/internal/bootstrap/config.go index ff36509c..27174c23 100644 --- a/internal/bootstrap/config.go +++ b/internal/bootstrap/config.go @@ -102,7 +102,13 @@ func initURL() { } func CleanTempDir() { - if err := os.RemoveAll(conf.Conf.TempDir); err != nil { - log.Errorln("failed delete temp file: ", err) + files, err := os.ReadDir(conf.Conf.TempDir) + if err != nil { + log.Errorln("failed list temp file: ", err) + } + for _, file := range files { + if err := os.RemoveAll(filepath.Join(conf.Conf.TempDir, file.Name())); err != nil { + log.Errorln("failed delete temp file: ", err) + } } } diff --git a/internal/op/fs.go b/internal/op/fs.go index e0153952..e49c941a 100644 --- a/internal/op/fs.go +++ b/internal/op/fs.go @@ -267,6 +267,12 @@ func Link(ctx context.Context, storage driver.Driver, path string, args model.Li } return link, nil } + + if storage.Config().OnlyLocal { + link, err := fn() + return link, file, err + } + link, err, _ := linkG.Do(key, fn) return link, file, err }