1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 15:57:07 +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

@ -16,6 +16,7 @@ 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"`
AccessTime time.Time `json:"atime"`
User uint32 `json:"user"` User uint32 `json:"user"`
Group uint32 `json:"group"` Group uint32 `json:"group"`
Content ID `json:"content,omitempty"` Content ID `json:"content,omitempty"`
@ -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

View file

@ -30,6 +30,7 @@ var _ = Describe("Tree", func() {
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"),
AccessTime: parseTime("2014-04-21T22:16:54.161401+02:00"),
User: 1000, User: 1000,
Group: 1001, Group: 1001,
Content: []byte{0x41, 0x42, 0x43}, Content: []byte{0x41, 0x42, 0x43},
@ -39,12 +40,13 @@ var _ = Describe("Tree", func() {
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"),
AccessTime: parseTime("2014-04-21T22:16:54.161401+02:00"),
Group: 1001, Group: 1001,
Content: []byte("\xde\xad\xbe\xef\xba\xdc\x0d\xe0"), 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() {