mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 03:18:55 +00:00
Create setNewFileMode function.
Create separate files with setNewFileMode to avoid runtime checks.
This commit is contained in:
parent
dfe232cf46
commit
520b1b65b0
@ -7,7 +7,6 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
@ -147,16 +146,7 @@ func (lb *localBlob) Finalize(t backend.Type, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// set file to readonly, except on Windows,
|
||||
// otherwise deletion will fail.
|
||||
if runtime.GOOS != "windows" {
|
||||
err = os.Chmod(f, fi.Mode()&os.FileMode(^uint32(0222)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return setNewFileMode(f, fi)
|
||||
}
|
||||
|
||||
// Create creates a new Blob. The data is available only after Finalize()
|
||||
|
12
backend/local/local_unix.go
Normal file
12
backend/local/local_unix.go
Normal file
@ -0,0 +1,12 @@
|
||||
// +build !windows
|
||||
|
||||
package local
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// set file to readonly
|
||||
func setNewFileMode(f string, fi os.FileInfo) error {
|
||||
return os.Chmod(f, fi.Mode()&os.FileMode(^uint32(0222)))
|
||||
}
|
12
backend/local/local_windows.go
Normal file
12
backend/local/local_windows.go
Normal file
@ -0,0 +1,12 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// 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 setNewFileMode(f string, fi os.FileInfo) error {
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user