Skip to content

Commit

Permalink
fix: broken file with local proxy (#7132 close #7112)
Browse files Browse the repository at this point in the history
* fix: local proxy download file damage

* fix: temp dir remove
  • Loading branch information
foxxorcat authored Sep 8, 2024
1 parent 4874c9e commit c9fa3d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/bootstrap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
6 changes: 6 additions & 0 deletions internal/op/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c9fa3d7

Please sign in to comment.