forked from TrueCloudLab/restic
Add atime to storage
This commit is contained in:
parent
d35a52da23
commit
2717d681c5
2 changed files with 23 additions and 19 deletions
|
@ -13,12 +13,13 @@ type Tree struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Mode os.FileMode `json:"mode"`
|
Mode os.FileMode `json:"mode"`
|
||||||
ModTime time.Time `json:"mtime"`
|
ModTime time.Time `json:"mtime"`
|
||||||
User uint32 `json:"user"`
|
AccessTime time.Time `json:"atime"`
|
||||||
Group uint32 `json:"group"`
|
User uint32 `json:"user"`
|
||||||
Content ID `json:"content,omitempty"`
|
Group uint32 `json:"group"`
|
||||||
|
Content ID `json:"content,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTree() *Tree {
|
func NewTree() *Tree {
|
||||||
|
@ -47,6 +48,7 @@ func NodeFromFileInfo(fi os.FileInfo) Node {
|
||||||
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
|
||||||
node.User = stat.Uid
|
node.User = stat.Uid
|
||||||
node.Group = stat.Gid
|
node.Group = stat.Gid
|
||||||
|
node.AccessTime = time.Unix(stat.Atim.Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
return node
|
return node
|
||||||
|
|
|
@ -27,24 +27,26 @@ var _ = Describe("Tree", func() {
|
||||||
t = new(storage.Tree)
|
t = new(storage.Tree)
|
||||||
t.Nodes = []storage.Node{
|
t.Nodes = []storage.Node{
|
||||||
storage.Node{
|
storage.Node{
|
||||||
Name: "foobar",
|
Name: "foobar",
|
||||||
Mode: 0755,
|
Mode: 0755,
|
||||||
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
|
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
|
||||||
User: 1000,
|
AccessTime: parseTime("2014-04-21T22:16:54.161401+02:00"),
|
||||||
Group: 1001,
|
User: 1000,
|
||||||
Content: []byte{0x41, 0x42, 0x43},
|
Group: 1001,
|
||||||
|
Content: []byte{0x41, 0x42, 0x43},
|
||||||
},
|
},
|
||||||
storage.Node{
|
storage.Node{
|
||||||
Name: "baz",
|
Name: "baz",
|
||||||
Mode: 0755,
|
Mode: 0755,
|
||||||
User: 1000,
|
User: 1000,
|
||||||
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
|
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
|
||||||
Group: 1001,
|
AccessTime: parseTime("2014-04-21T22:16:54.161401+02:00"),
|
||||||
Content: []byte("\xde\xad\xbe\xef\xba\xdc\x0d\xe0"),
|
Group: 1001,
|
||||||
|
Content: []byte("\xde\xad\xbe\xef\xba\xdc\x0d\xe0"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
raw = `{"nodes":[{"name":"foobar","mode":493,"mtime":"2014-04-20T22:16:54.161401+02:00","user":1000,"group":1001,"content":"414243"},{"name":"baz","mode":493,"mtime":"2014-04-20T22:16:54.161401+02:00","user":1000,"group":1001,"content":"deadbeefbadc0de0"}]}`
|
raw = `{"nodes":[{"name":"foobar","mode":493,"mtime":"2014-04-20T22:16:54.161401+02:00","atime":"2014-04-21T22:16:54.161401+02:00","user":1000,"group":1001,"content":"414243"},{"name":"baz","mode":493,"mtime":"2014-04-20T22:16:54.161401+02:00","atime":"2014-04-21T22:16:54.161401+02:00","user":1000,"group":1001,"content":"deadbeefbadc0de0"}]}`
|
||||||
})
|
})
|
||||||
|
|
||||||
It("Should save", func() {
|
It("Should save", func() {
|
||||||
|
|
Loading…
Reference in a new issue