Skip to content

Commit

Permalink
Fixed mtime issue for OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-prindle committed Jun 15, 2017
1 parent 084eeaf commit e23250d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion third_party/go9p/srv_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package go9p

import (
"log"
"runtime"
"sync"
"time"
)
Expand Down Expand Up @@ -132,7 +133,13 @@ func (f *srvFile) Add(dir *srvFile, name string, uid User, gid Group, mode uint3
f.Qid.Version = 0
f.Qid.Path = qpath
f.Mode = mode
f.Atime = uint32(time.Now().Unix())
// macOS filesystem st_mtime values are only accurate to the second
// without truncating, 9p will invent a changing fractional time #1375
if runtime.GOOS == "darwin" {
f.Atime = uint32(time.Now().Truncate(time.Second).Unix())
} else {
f.Atime = uint32(time.Now().Unix())
}
f.Mtime = f.Atime
f.Length = 0
f.Name = name
Expand Down
4 changes: 3 additions & 1 deletion third_party/go9p/ufs_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ func (u *Ufs) Wstat(req *SrvReq) {
//at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
}
}
e := os.Chtimes(fid.path, at, mt)
// macOS filesystem st_mtime values are only accurate to the second
// this ensures, 9p will only write mtime to the second #1375
e := os.Chtimes(fid.path, at.Truncate(time.Second), mt.Truncate(time.Second))
if e != nil {
req.RespondError(toError(e))
return
Expand Down

0 comments on commit e23250d

Please sign in to comment.