From 72add5ab27b3be7266265ab035ea4b53e89b59db Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 8 Jul 2017 15:42:18 +0100 Subject: [PATCH] sync: state whether duplicates are objects are directories --- fs/operations.go | 12 ++++++++++++ fs/sync.go | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fs/operations.go b/fs/operations.go index ebbfe1ed6..045728525 100644 --- a/fs/operations.go +++ b/fs/operations.go @@ -590,6 +590,18 @@ func (ds DirEntries) ForDirError(fn func(dir Directory) error) error { return nil } +// DirEntryType returns a string description of the DirEntry, either +// "object", "directory" or "unknown type XXX" +func DirEntryType(d DirEntry) string { + switch d.(type) { + case Object: + return "object" + case Directory: + return "directory" + } + return fmt.Sprintf("unknown type %T", d) +} + // ListDirSorted reads Object and *Dir into entries for the given Fs. // // dir is the start directory, "" for root diff --git a/fs/sync.go b/fs/sync.go index bbd6a442b..601d948f4 100644 --- a/fs/sync.go +++ b/fs/sync.go @@ -866,7 +866,7 @@ func matchListings(srcList, dstList DirEntries) (srcOnly DirEntries, dstOnly Dir if src != nil && iSrc > 0 { prev := srcList[iSrc-1].Remote() if srcRemote == prev { - Logf(src, "Duplicate file found in source - ignoring") + Logf(src, "Duplicate %s found in source - ignoring", DirEntryType(src)) src = nil // ignore the src } else if srcRemote < prev { Errorf(src, "Out of order listing in source") @@ -876,7 +876,7 @@ func matchListings(srcList, dstList DirEntries) (srcOnly DirEntries, dstOnly Dir if dst != nil && iDst > 0 { prev := dstList[iDst-1].Remote() if dstRemote == prev { - Logf(dst, "Duplicate file found in destination - ignoring") + Logf(dst, "Duplicate %s found in destination - ignoring", DirEntryType(dst)) dst = nil // ignore the dst } else if dstRemote < prev { Errorf(dst, "Out of order listing in destination")