lib/protocol, lib/model: Implement high precision time stamps (fixes #3305)
This adds a new nanoseconds field to the FileInfo, populates it during scans and sets the non-truncated time in Chtimes calls. The actual file modification time is defined as modified_s seconds + modified_ns nanoseconds. It's expected that the modified_ns field is <= 1e9 (that is, all whole seconds should go in the modified_s field) but not really enforced. Given that it's an int32 the timestamp can be adjusted += ~2.9 seconds by the modified_ns field... GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3431
This commit is contained in:
committed by
Audrius Butkevicius
parent
0655991a19
commit
ea87bcefd6
@@ -9,6 +9,7 @@ package model
|
||||
import (
|
||||
"math/rand"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/sync"
|
||||
)
|
||||
@@ -22,7 +23,7 @@ type jobQueue struct {
|
||||
type jobQueueEntry struct {
|
||||
name string
|
||||
size int64
|
||||
modified int64
|
||||
modified time.Time
|
||||
}
|
||||
|
||||
func newJobQueue() *jobQueue {
|
||||
@@ -31,7 +32,7 @@ func newJobQueue() *jobQueue {
|
||||
}
|
||||
}
|
||||
|
||||
func (q *jobQueue) Push(file string, size, modified int64) {
|
||||
func (q *jobQueue) Push(file string, size int64, modified time.Time) {
|
||||
q.mut.Lock()
|
||||
q.queued = append(q.queued, jobQueueEntry{file, size, modified})
|
||||
q.mut.Unlock()
|
||||
@@ -160,5 +161,5 @@ func (q smallestFirst) Swap(a, b int) { q[a], q[b] = q[b], q[a] }
|
||||
type oldestFirst []jobQueueEntry
|
||||
|
||||
func (q oldestFirst) Len() int { return len(q) }
|
||||
func (q oldestFirst) Less(a, b int) bool { return q[a].modified < q[b].modified }
|
||||
func (q oldestFirst) Less(a, b int) bool { return q[a].modified.Before(q[b].modified) }
|
||||
func (q oldestFirst) Swap(a, b int) { q[a], q[b] = q[b], q[a] }
|
||||
|
||||
Reference in New Issue
Block a user