forked from TrueCloudLab/rclone
fs: fix duplicate files causing spurious copies
Before this fix duplicate files (on Google Drive) caused the next file to be spuriously copied. `rclone dedupe` worked around the problem.
This commit is contained in:
parent
b7521c0fe2
commit
00fe6d95da
2 changed files with 12 additions and 20 deletions
14
fs/march.go
14
fs/march.go
|
@ -268,20 +268,22 @@ func matchListings(srcListEntries, dstListEntries DirEntries, transforms []match
|
||||||
prev := srcList[iSrc-1].name
|
prev := srcList[iSrc-1].name
|
||||||
if srcName == prev {
|
if srcName == prev {
|
||||||
Logf(src, "Duplicate %s found in source - ignoring", DirEntryType(src))
|
Logf(src, "Duplicate %s found in source - ignoring", DirEntryType(src))
|
||||||
src = nil // ignore the src
|
iDst-- // ignore the src and retry the dst
|
||||||
|
continue
|
||||||
} else if srcName < prev {
|
} else if srcName < prev {
|
||||||
Errorf(src, "Out of order listing in source")
|
// this should never happen since we sort the listings
|
||||||
src = nil // ignore the src
|
panic("Out of order listing in source")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dst != nil && iDst > 0 {
|
if dst != nil && iDst > 0 {
|
||||||
prev := dstList[iDst-1].name
|
prev := dstList[iDst-1].name
|
||||||
if dstName == prev {
|
if dstName == prev {
|
||||||
Logf(dst, "Duplicate %s found in destination - ignoring", DirEntryType(dst))
|
Logf(dst, "Duplicate %s found in destination - ignoring", DirEntryType(dst))
|
||||||
dst = nil // ignore the dst
|
iSrc-- // ignore the dst and retry the src
|
||||||
|
continue
|
||||||
} else if dstName < prev {
|
} else if dstName < prev {
|
||||||
Errorf(dst, "Out of order listing in destination")
|
// this should never happen since we sort the listings
|
||||||
dst = nil // ignore the dst
|
panic("Out of order listing in destination")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if src != nil && dst != nil {
|
if src != nil && dst != nil {
|
||||||
|
|
|
@ -101,11 +101,15 @@ func TestMatchListings(t *testing.T) {
|
||||||
{
|
{
|
||||||
what: "One duplicate",
|
what: "One duplicate",
|
||||||
input: DirEntries{
|
input: DirEntries{
|
||||||
|
A, A,
|
||||||
a, a,
|
a, a,
|
||||||
a, nil,
|
a, nil,
|
||||||
|
b, b,
|
||||||
},
|
},
|
||||||
matches: []matchPair{
|
matches: []matchPair{
|
||||||
|
{A, A},
|
||||||
{a, a},
|
{a, a},
|
||||||
|
{b, b},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -141,20 +145,6 @@ func TestMatchListings(t *testing.T) {
|
||||||
},
|
},
|
||||||
transforms: []matchTransformFn{strings.ToLower},
|
transforms: []matchTransformFn{strings.ToLower},
|
||||||
},
|
},
|
||||||
/*{
|
|
||||||
what: "Out of order",
|
|
||||||
input: DirEntries{
|
|
||||||
c, nil,
|
|
||||||
b, b,
|
|
||||||
a, nil,
|
|
||||||
},
|
|
||||||
srcOnly: DirEntries{
|
|
||||||
c,
|
|
||||||
},
|
|
||||||
dstOnly: DirEntries{
|
|
||||||
b,
|
|
||||||
},
|
|
||||||
},*/
|
|
||||||
} {
|
} {
|
||||||
var srcList, dstList DirEntries
|
var srcList, dstList DirEntries
|
||||||
for i := 0; i < len(test.input); i += 2 {
|
for i := 0; i < len(test.input); i += 2 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue