mirror of
https://github.com/restic/restic.git
synced 2026-02-15 00:34:36 -05:00
If the repo is on a mounted folder that doesn't support chmod (like SMB), it was causing an "operation not supported" error when trying to chmod 666 a file before deleting it. But it isn't generally needed before deleting a file (the folder permissions matter there, not the file permissions). So, just drop it.
31 lines
708 B
Go
31 lines
708 B
Go
package local
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/restic/restic/internal/errors"
|
|
)
|
|
|
|
// Can't explicitly flush directory changes on Windows.
|
|
func fsyncDir(_ string) error { return nil }
|
|
|
|
// Windows is not macOS.
|
|
func isMacENOTTY(_ error) bool { return false }
|
|
|
|
// We don't modify read-only on windows,
|
|
// since it will make us unable to delete the file,
|
|
// and this isn't common practice on this platform.
|
|
func setFileReadonly(_ string, _ os.FileMode) error {
|
|
return nil
|
|
}
|
|
|
|
func removeFile(f string) error {
|
|
// Reset read-only flag,
|
|
// as Windows won't let you delete a read-only file
|
|
err := os.Chmod(f, 0666)
|
|
if err != nil && !os.IsPermission(err) {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
return os.Remove(f)
|
|
}
|