fix: broken file with local proxy (#7132 close #7112)

* fix: local proxy download file damage

* fix: temp dir remove
pull/7139/head
foxxorcat 2024-09-08 10:44:34 +08:00 committed by GitHub
parent 4874c9e43b
commit c9fa3d7cd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -102,7 +102,13 @@ func initURL() {
} }
func CleanTempDir() { func CleanTempDir() {
if err := os.RemoveAll(conf.Conf.TempDir); err != nil { files, err := os.ReadDir(conf.Conf.TempDir)
log.Errorln("failed delete temp file: ", err) 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)
}
} }
} }

View File

@ -267,6 +267,12 @@ func Link(ctx context.Context, storage driver.Driver, path string, args model.Li
} }
return link, nil return link, nil
} }
if storage.Config().OnlyLocal {
link, err := fn()
return link, file, err
}
link, err, _ := linkG.Do(key, fn) link, err, _ := linkG.Do(key, fn)
return link, file, err return link, file, err
} }