Skip to content

operations: fix possible unintended --size-only skip with multithread… - #6284

Closed
Evan-sp wants to merge 1 commit into
rclone:masterfrom
Evan-sp:multithread-withhold-byte
Closed

Evan-sp wants to merge 1 commit into
rclone:masterfrom
Evan-sp:multithread-withhold-byte

Conversation

@Evan-sp

@Evan-sp Evan-sp commented Jun 28, 2022

Copy link
Copy Markdown

… copy

What is the purpose of this change?

Fix #6206 by withholding the very last byte until the rest of the transfer is complete

Was the change discussed in an issue or in the forum before?

#6206

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

… copy

If doing a copy from a remote to local with multiple streams and --size-only (either explicit or implied by the remote, e.g., WebDAV), it is conceivable for an interrupted transfer to not get restarted since it's "size" is correct even if the content is not. This was fixed by withholding the very last byte until the rest of the transfer is complete. This way, the size of the file always mismatches until completed

Fixes rclone#6206
@Jwink3101

Copy link
Copy Markdown
Contributor

Is there an update on this? Plan to merge?

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great idea.

The implementation could be made more efficient though - please see inline.

return nil, err
}

// Copy last withheld byte

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Open will cause another HTTP transaction to the backend and hence quite a lot of extra work / delay for each file.

Ideally what we'd do is fetch the last byte above where we have the connection open, stash it away, and store it here.

@Jwink3101

Copy link
Copy Markdown
Contributor

I mentioned in the original forum post that an alternative would be to preallocate an extra byte and truncate. Since this is only for local destination, can all local remotes support truncate? That would solve the book-keeping and be simple.

@ncw

ncw commented Oct 6, 2022

Copy link
Copy Markdown
Member

Yes that seems like a good idea.

You should be able to truncate the file with OpenWriterAt by opening it again I think.

We could always add truncate to that interface if necessary.

@Jwink3101

Copy link
Copy Markdown
Contributor

Just checking if there has been any progress on this? It is a conceivable scenario and it worries me that we aren't protected. (e.g., downloading WebDAV to local).

@ncw? @Evan-sp

@ncw

ncw commented Feb 23, 2023

Copy link
Copy Markdown
Member

I'd like to get the efficiency thing resolved, either by keeping the last byte, or using the preallocate trick.

@Evan-sp do you want to have a go at this? If not how about you @Jwink3101 ?

@ncw

ncw commented Jun 23, 2023

Copy link
Copy Markdown
Member

In 5c594fe we implemented transfers to a temporary file name on the local, ftp and sftp backends unless the --inplace flag is not used.

I think this therefore fixes the issue that this PR is intended to fix as the file won't be renamed to its proper name unless the download completes properly.

I'm therefore going to close this PR.

Thank you @Evan-sp for doing it and sorry we didn't get it merged.

@ncw ncw closed this Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make rclone more robust to false-negatives with local copies and --size-only

3 participants