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
1 changed files with 7 additions and 1 deletions

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