storage/file-misc.go | 7 ++++++- diff --git a/storage/file-misc.go b/storage/file-misc.go index 9d6ff33f0baa693b4ae5a0b092c7bc5f6b934839..afa65f44369cd8ac4a2e81e04461699cde6d7045 100644 --- a/storage/file-misc.go +++ b/storage/file-misc.go @@ -45,8 +45,13 @@ // caller should make sure the file name provided is safe/sanitized. func CreateNativeZeroLengthFile(name string) error { os.MkdirAll(filepath.Dir(name), dirPerm) var f io.Closer - f, err := os.Create(name) + // Must request write perms to create and trunc. But we don't need those for a zero-length file. + f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, filePerm) if err != nil { + stat, statErr := os.Stat(name) + if statErr == nil && stat.Mode().IsRegular() && stat.Size() == 0 { + return nil + } return err } return f.Close()