Skip to content

vfs: serve sftp is reporting incorrect hashes when used with --vfs-cache-mode full #4956

Open

Description

@sp31415t1

Hi,

I'm making a bug report as invited on forum.
https://forum.rclone.org/t/rclone-serve-sftp-how-to-avoid-to-store-incomplete-transferred-files/21825

What is the problem you are having with rclone?

Using rclone serve sftp and rclone sync
In case a file has been interrupted during the transfer (like ctrl+c)
It needs 2 transfer/upload in order to 'receive' the correct file

What is your rclone version (output from rclone version)

1.53.3

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

linux amd64

Which cloud storage system are you using? (e.g. Google Drive)

local

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

Nick reproduce using :
rclone serve -vv sftp --user x --pass x --vfs-cache-mode writes /tmp/sftptest/
rclone sync -P -vv --sftp-host localhost --sftp-port 2022 --bwlimit 100k src :sftp:

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

ERROR : Attempt 1/3 failed with 1 errors and: corrupted on transfer: MD5 hash differ
ERROR : Attempt 2/3 succeeded

Activity

  1. added this to the v1.55 milestone on Jan 25, 2021
  2. changed the title [-]rclone serve sftp needs 2 uploads to save over an existing file[/-] [+]vfs: serve sftp is reporting incorrect hashes when used with --vfs-cache-mode full[/+] on Jan 25, 2021
  3. ncw commented on Jan 25, 2021

    @ncw
    Member

    I reproduced this with

    rclone serve -vv sftp --user x --pass x --vfs-cache-mode writes /tmp/sftptest/
    

    And

    rclone sync -P -vv --sftp-host localhost --sftp-port 2022 --bwlimit 100k src :sftp:
    

    I think I see what is going on here.

    • first upload uploads a partial file
    • partial file is uploaded from vfs cache to /tmp/sftptest/
    • retry uploads a full file - this goes to the vfs cache /path/to/vfscache/1M
    • MD5SUM is checked from /tmp/sftptest/1M not /path/to/vfscache/1M
    • Checksums don't match so a retry is initiated

    You can see this is the problem if you use this on the sending command

    --sftp-md5sum-command none  --sftp-sha1sum-command none
    

    Then it will only do 1 transfer not 2.

    What needs to be done here is implement a Hash() method on VFS objects which can read either from the remote object, or from the local cached copy if present.

    This needs to be used in the Etag method in cmd serve webdav

    hash, err := o.Hash(ctx, hashType)

    And in the md5sum/sha1sum commands in cmd serve sftp

    hashSum, err = o.Hash(ctx, ht)

  4. modified the milestones: v1.55, v1.56 on Apr 3, 2021
  5. modified the milestones: v1.56, v1.57 on Jul 20, 2021
  6. modified the milestones: v1.57, Known Problem on Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions