Use ModTime on systems that don't provide Atim file stat field
This commit is contained in:
parent
4a9f127ecc
commit
1bf3cb81b3
3 changed files with 29 additions and 8 deletions
17
store/atime_linux.go
Normal file
17
store/atime_linux.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
// +build linux
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func timespecToTime(ts syscall.Timespec) time.Time {
|
||||
return time.Unix(int64(ts.Sec), int64(ts.Nsec))
|
||||
}
|
||||
|
||||
func atime(fi os.FileInfo) time.Time {
|
||||
return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim)
|
||||
}
|
12
store/atime_universal.go
Normal file
12
store/atime_universal.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
// +build !linux
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func atime(fi os.FileInfo) time.Time {
|
||||
return fi.ModTime()
|
||||
}
|
|
@ -227,11 +227,3 @@ func (d *DiskBlobStore) WipeOldestBlobs() (err error) {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func timespecToTime(ts syscall.Timespec) time.Time {
|
||||
return time.Unix(int64(ts.Sec), int64(ts.Nsec))
|
||||
}
|
||||
|
||||
func atime(fi os.FileInfo) time.Time {
|
||||
return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue