1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-21 23:33:03 +00:00

Add atime to storage

This commit is contained in:
Alexander Neumann 2014-04-27 23:59:58 +02:00
parent d35a52da23
commit 2717d681c5
2 changed files with 23 additions and 19 deletions

View file

@ -13,12 +13,13 @@ type Tree struct {
}
type Node struct {
Name string `json:"name"`
Mode os.FileMode `json:"mode"`
ModTime time.Time `json:"mtime"`
User uint32 `json:"user"`
Group uint32 `json:"group"`
Content ID `json:"content,omitempty"`
Name string `json:"name"`
Mode os.FileMode `json:"mode"`
ModTime time.Time `json:"mtime"`
AccessTime time.Time `json:"atime"`
User uint32 `json:"user"`
Group uint32 `json:"group"`
Content ID `json:"content,omitempty"`
}
func NewTree() *Tree {
@ -47,6 +48,7 @@ func NodeFromFileInfo(fi os.FileInfo) Node {
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
node.User = stat.Uid
node.Group = stat.Gid
node.AccessTime = time.Unix(stat.Atim.Unix())
}
return node

View file

@ -27,24 +27,26 @@ var _ = Describe("Tree", func() {
t = new(storage.Tree)
t.Nodes = []storage.Node{
storage.Node{
Name: "foobar",
Mode: 0755,
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
User: 1000,
Group: 1001,
Content: []byte{0x41, 0x42, 0x43},
Name: "foobar",
Mode: 0755,
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
AccessTime: parseTime("2014-04-21T22:16:54.161401+02:00"),
User: 1000,
Group: 1001,
Content: []byte{0x41, 0x42, 0x43},
},
storage.Node{
Name: "baz",
Mode: 0755,
User: 1000,
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
Group: 1001,
Content: []byte("\xde\xad\xbe\xef\xba\xdc\x0d\xe0"),
Name: "baz",
Mode: 0755,
User: 1000,
ModTime: parseTime("2014-04-20T22:16:54.161401+02:00"),
AccessTime: parseTime("2014-04-21T22:16:54.161401+02:00"),
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() {