MCPcopy Index your code
hub / github.com/rclone/rclone / Match

Method Match

fs/sync/sync.go:1272–1330  ·  view source on GitHub ↗

Match is called when src and dst are present, so sync src to dst

(ctx context.Context, dst, src fs.DirEntry)

Source from the content-addressed store, hash-verified

1270
1271// Match is called when src and dst are present, so sync src to dst
1272func (s *syncCopyMove) Match(ctx context.Context, dst, src fs.DirEntry) (recurse bool) {
1273 switch srcX := src.(type) {
1274 case fs.Object:
1275 s.markParentNotEmpty(src)
1276
1277 if s.deleteMode == fs.DeleteModeOnly {
1278 return false
1279 }
1280 dstX, ok := dst.(fs.Object)
1281 if ok {
1282 // No logger here because we'll handle it in equal()
1283 ok = s.toBeChecked.Put(s.inCtx, fs.ObjectPair{Src: srcX, Dst: dstX})
1284 if !ok {
1285 return false
1286 }
1287 } else {
1288 // FIXME src is file, dst is directory
1289 err := errors.New("can't overwrite directory with file")
1290 fs.Errorf(dst, "%v", err)
1291 s.processError(err)
1292 s.logger(ctx, operations.TransferError, srcX, dstX, err)
1293 }
1294 case fs.Directory:
1295 // Do the same thing to the entire contents of the directory
1296 srcX = fs.NewOverrideDirectory(srcX, transform.Path(ctx, src.Remote(), true))
1297 src = srcX
1298 if !transform.Transforming(ctx) || src.Remote() != dst.Remote() {
1299 s.markParentNotEmpty(src)
1300 }
1301 dstX, ok := dst.(fs.Directory)
1302 if ok {
1303 s.logger(s.ctx, operations.Match, src, dst, fs.ErrorIsDir)
1304 // Create the directory and make sure the Metadata/ModTime is correct
1305 s.copyDirMetadata(s.ctx, s.fdst, dstX, "", srcX)
1306
1307 if s.ci.FixCase && !s.ci.Immutable && src.Remote() != dst.Remote() {
1308 // Fix case for case insensitive filesystems
1309 // Fix each dir before recursing into subdirs and files
1310 err := operations.DirMoveCaseInsensitive(s.ctx, s.fdst, dst.Remote(), src.Remote())
1311 if err != nil {
1312 fs.Errorf(dst, "Error while attempting to rename to %s: %v", src.Remote(), err)
1313 s.processError(err)
1314 } else {
1315 fs.Infof(dst, "Fixed case by renaming to: %s", src.Remote())
1316 }
1317 }
1318
1319 return true
1320 }
1321 // FIXME src is dir, dst is file
1322 err := errors.New("can't overwrite file with directory")
1323 fs.Errorf(dst, "%v", err)
1324 s.processError(err)
1325 s.logger(ctx, operations.TransferError, src.(fs.ObjectInfo), dst.(fs.ObjectInfo), err)
1326 default:
1327 panic("Bad object in DirEntries")
1328 }
1329 return false

Callers

nothing calls this directly

Calls 11

markParentNotEmptyMethod · 0.95
processErrorMethod · 0.95
copyDirMetadataMethod · 0.95
ErrorfFunction · 0.92
NewOverrideDirectoryFunction · 0.92
PathFunction · 0.92
TransformingFunction · 0.92
DirMoveCaseInsensitiveFunction · 0.92
InfofFunction · 0.92
PutMethod · 0.65
RemoteMethod · 0.65

Tested by

no test coverage detected