Why use 'c.remoteForCopy' instead of 'c.remote' to check length in copy operation?

rclone is a fantastic project that I both use and study its source code. I have a question regarding its copy implementation.

In checkPartial(), it checks the length of c.remoteForCopy instead of c.remote.

I noticed that the copy object is initialized with a default empty string for the attribute remoteForCopy. I suspect that remoteForCopy in copy may never be assigned a value. This confusion leads me to wonder when c.remoteForCopy is assigned a value.

I think you might be right. Perhaps at 101 and 103 it should be remoteForCopy (assigned at 91) instead of c.remoteForCopy?

1 Like

I think you are right.

That got broken when I refactored it to use a utility object...

2 Likes

Hi, Nick, thanks for your efforts, hope you can fix it if it is a bug.

@zhiweio want to send a PR to fix it?

1 Like

I won't be available until next week, so you can handle it.

I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.67 and 1.66.1

In the rclone copy implementation, the remoteForCopy attribute of the copy object is initialized with the value of c.remote during the checkPartial() function call. The initialization of the copy object happens in the copyFile() function where c.remote is set to the source remote location (remote) specified for the copy operation. Later, when checkPartial() is called, remoteForCopy is updated based on certain conditions related to partial uploads and filename length considerations. Therefore, remoteForCopy does get assigned a value based on the logic inside checkPartial(), which modifies it according to the specific copy operation settings and constraints.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.