local: add --local-time-type to use mtime/atime/btime/ctime as the time
Fixes #7484
This commit is contained in:
parent
854a36c4ab
commit
ac6ba11d22
6 changed files with 138 additions and 2 deletions
|
@ -5,12 +5,29 @@ package local
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
)
|
||||
|
||||
// Read the time specified from the os.FileInfo
|
||||
func readTime(t timeType, fi os.FileInfo) time.Time {
|
||||
stat, ok := fi.Sys().(*syscall.Stat_t)
|
||||
if !ok {
|
||||
fs.Debugf(nil, "didn't return Stat_t as expected")
|
||||
return fi.ModTime()
|
||||
}
|
||||
switch t {
|
||||
case aTime:
|
||||
return time.Unix(stat.Atim.Unix())
|
||||
case cTime:
|
||||
return time.Unix(stat.Ctim.Unix())
|
||||
}
|
||||
return fi.ModTime()
|
||||
}
|
||||
|
||||
// Read the metadata from the file into metadata where possible
|
||||
func (o *Object) readMetadataFromFile(m *fs.Metadata) (err error) {
|
||||
info, err := o.fs.lstat(o.path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue