mirror of
https://github.com/restic/restic.git
synced 2024-09-10 13:20:53 +02:00
49 lines
975 B
Go
49 lines
975 B
Go
package backend
|
|
|
|
import "os"
|
|
|
|
// Paths contains the default paths for file-based backends (e.g. local).
|
|
var Paths = struct {
|
|
Data string
|
|
Snapshots string
|
|
Index string
|
|
Locks string
|
|
Keys string
|
|
Temp string
|
|
Config string
|
|
}{
|
|
"data",
|
|
"snapshots",
|
|
"index",
|
|
"locks",
|
|
"keys",
|
|
"tmp",
|
|
"config",
|
|
}
|
|
|
|
type Modes struct {
|
|
Dir os.FileMode
|
|
File os.FileMode
|
|
}
|
|
|
|
// DefaultModes defines the default permissions to apply to new repository
|
|
// files and directories stored on file-based backends.
|
|
var DefaultModes = Modes{Dir: 0700, File: 0600}
|
|
|
|
// DeriveModesFromFileInfo will, given the mode of a regular file, compute
|
|
// the mode we should use for new files and directories. If the passed
|
|
// error is non-nil DefaultModes are returned.
|
|
func DeriveModesFromFileInfo(fi os.FileInfo, err error) Modes {
|
|
m := DefaultModes
|
|
if err != nil {
|
|
return m
|
|
}
|
|
|
|
if fi.Mode()&0040 != 0 { // Group has read access
|
|
m.Dir |= 0070
|
|
m.File |= 0060
|
|
}
|
|
|
|
return m
|
|
}
|