2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-12 16:26:34 +00:00
restic/internal/backend/paths.go

49 lines
975 B
Go
Raw Normal View History

2015-03-28 10:50:23 +00:00
package backend
import "os"
2016-01-26 20:56:13 +00:00
// Paths contains the default paths for file-based backends (e.g. local).
2015-03-28 10:50:23 +00:00
var Paths = struct {
Data string
Snapshots string
2015-04-26 13:48:35 +00:00
Index string
2015-03-28 10:50:23 +00:00
Locks string
Keys string
Temp string
Config string
2015-03-28 10:50:23 +00:00
}{
"data",
"snapshots",
2015-04-26 13:48:35 +00:00
"index",
2015-03-28 10:50:23 +00:00
"locks",
"keys",
"tmp",
"config",
2015-03-28 10:50:23 +00:00
}
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
}