repository: remove redundant cleanup code

The temp files used by the packer manager are either delete after
creation (unix) or marked as delete on close (windows). Thus, no
explicit cleanup is necessary.
This commit is contained in:
Michael Eischer 2024-07-21 15:00:34 +02:00
parent 0ddb4441d7
commit 80ed863aab
2 changed files with 0 additions and 18 deletions

View file

@ -88,15 +88,6 @@ func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) {
return os.OpenFile(fixpath(name), flag, perm)
}
// RemoveIfExists removes a file, returning no error if it does not exist.
func RemoveIfExists(filename string) error {
err := os.Remove(filename)
if err != nil && os.IsNotExist(err) {
err = nil
}
return err
}
// Chtimes changes the access and modification times of the named file,
// similar to the Unix utime() or utimes() functions.
//

View file

@ -6,7 +6,6 @@ import (
"crypto/sha256"
"io"
"os"
"runtime"
"sync"
"github.com/restic/restic/internal/backend"
@ -186,14 +185,6 @@ func (r *Repository) savePacker(ctx context.Context, t restic.BlobType, p *packe
return errors.Wrap(err, "close tempfile")
}
// on windows the tempfile is automatically deleted on close
if runtime.GOOS != "windows" {
err = fs.RemoveIfExists(p.tmpfile.Name())
if err != nil {
return errors.WithStack(err)
}
}
// update blobs in the index
debug.Log(" updating blobs %v to pack %v", p.Packer.Blobs(), id)
r.idx.StorePack(id, p.Packer.Blobs())