MCPcopy
hub / github.com/rclone/rclone / ModTime

Method ModTime

vfs/file.go:380–421  ·  view source on GitHub ↗

ModTime returns the modified time of the file if NoModTime is set then it returns the mod time of the directory

()

Source from the content-addressed store, hash-verified

378//
379// if NoModTime is set then it returns the mod time of the directory
380func (f *File) ModTime() (modTime time.Time) {
381 f.mu.RLock()
382 d, o, pendingModTime, virtualModTime := f.d, f.o, f.pendingModTime, f.virtualModTime
383 f.mu.RUnlock()
384
385 // Set the virtual modtime up for backends which don't support setting modtime
386 //
387 // Note that we only cache modtime values that we have returned to the OS
388 // if we haven't returned a value to the OS then we can change it
389 defer func() {
390 if f.d.f.Precision() == fs.ModTimeNotSupported && (virtualModTime == nil || !virtualModTime.Equal(modTime)) {
391 f.virtualModTime = &modTime
392 fs.Debugf(f._path(), "Set virtual modtime to %v", f.virtualModTime)
393 }
394 }()
395
396 if d.vfs.Opt.NoModTime {
397 return d.ModTime()
398 }
399 // Read the modtime from a dirty item if it exists
400 if f.d.vfs.Opt.CacheMode >= vfscommon.CacheModeMinimal {
401 if item := f.d.vfs.cache.DirtyItem(f._cachePath()); item != nil {
402 modTime, err := item.GetModTime()
403 if err != nil {
404 fs.Errorf(f._path(), "ModTime: Item GetModTime failed: %v", err)
405 } else {
406 return f._roundModTime(modTime)
407 }
408 }
409 }
410 if !pendingModTime.IsZero() {
411 return f._roundModTime(pendingModTime)
412 }
413 if virtualModTime != nil && !virtualModTime.IsZero() {
414 fs.Debugf(f._path(), "Returning virtual modtime %v", f.virtualModTime)
415 return f._roundModTime(*virtualModTime)
416 }
417 if o == nil {
418 return time.Now()
419 }
420 return o.ModTime(f.ctx)
421}
422
423// nonNegative returns 0 if i is -ve, i otherwise
424func nonNegative(i int64) int64 {

Callers

nothing calls this directly

Calls 11

_pathMethod · 0.95
_cachePathMethod · 0.95
_roundModTimeMethod · 0.95
DebugfFunction · 0.92
ErrorfFunction · 0.92
DirtyItemMethod · 0.80
IsZeroMethod · 0.80
PrecisionMethod · 0.65
ModTimeMethod · 0.65
EqualMethod · 0.45
GetModTimeMethod · 0.45

Tested by

no test coverage detected