2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-08 12:00:49 +00:00

cache: Don't recreate CACHEDIR.TAG

This commit is contained in:
Alexander Neumann 2018-07-08 12:05:12 +02:00
parent b511f4dce2
commit bd742ddb69

View File

@ -61,7 +61,13 @@ func writeCachedirTag(dir string) error {
return err
}
f, err := fs.OpenFile(filepath.Join(dir, "CACHEDIR.TAG"), os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
tagfile := filepath.Join(dir, "CACHEDIR.TAG")
_, err := fs.Lstat(tagfile)
if err != nil && !os.IsNotExist(err) {
return errors.Wrap(err, "Lstat")
}
f, err := fs.OpenFile(tagfile, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
if err != nil {
if os.IsExist(errors.Cause(err)) {
return nil