forked from TrueCloudLab/rclone
bisync: isDir check for deltas
Before this change, if --create-empty-src-dirs was specified, bisync would include directories in the list of deltas to evaluate by their modtime, relative to the prior sync. This was unnecessary, as rclone does not yet support setting modtime for directories. After this change, we skip directories when comparing modtimes. (In other words, we care only if a directory is created or deleted, not whether it is newer or older.)
This commit is contained in:
parent
978cbf9360
commit
079763f09a
2 changed files with 24 additions and 10 deletions
|
@ -174,6 +174,8 @@ func (b *bisyncRun) findDeltas(fctx context.Context, f fs.Fs, oldListing, newLis
|
||||||
ds.deleted++
|
ds.deleted++
|
||||||
d |= deltaDeleted
|
d |= deltaDeleted
|
||||||
} else {
|
} else {
|
||||||
|
// skip dirs here, as we only care if they are new/deleted, not newer/older
|
||||||
|
if !now.isDir(file) {
|
||||||
if old.getTime(file) != now.getTime(file) {
|
if old.getTime(file) != now.getTime(file) {
|
||||||
if old.beforeOther(now, file) {
|
if old.beforeOther(now, file) {
|
||||||
fs.Debugf(file, "(old: %v current: %v", old.getTime(file), now.getTime(file))
|
fs.Debugf(file, "(old: %v current: %v", old.getTime(file), now.getTime(file))
|
||||||
|
@ -187,6 +189,7 @@ func (b *bisyncRun) findDeltas(fctx context.Context, f fs.Fs, oldListing, newLis
|
||||||
}
|
}
|
||||||
// TODO Compare sizes and hashes
|
// TODO Compare sizes and hashes
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if d.is(deltaModified) {
|
if d.is(deltaModified) {
|
||||||
ds.deltas[file] = d
|
ds.deltas[file] = d
|
||||||
|
|
|
@ -128,6 +128,17 @@ func (ls *fileList) getTime(file string) time.Time {
|
||||||
return fi.time
|
return fi.time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// also returns false if not found
|
||||||
|
func (ls *fileList) isDir(file string) bool {
|
||||||
|
fi := ls.get(file)
|
||||||
|
if fi != nil {
|
||||||
|
if fi.flags == "d" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (ls *fileList) beforeOther(other *fileList, file string) bool {
|
func (ls *fileList) beforeOther(other *fileList, file string) bool {
|
||||||
thisTime := ls.getTime(file)
|
thisTime := ls.getTime(file)
|
||||||
thatTime := other.getTime(file)
|
thatTime := other.getTime(file)
|
||||||
|
|
Loading…
Reference in a new issue