Skip to content

md5sum file support #157

Closed
Closed

Description

@klauspost

Would it be an improvement if local filesystem would read ".md5" files, so it could get checksums without reading the file?

If you aren't against it, I wouldn't mind implementing it. Of course it should check the file modified times.

I would try to make it generic, so it could also be used by other filesystems without native checksum support.

Activity

  1. ncw commented on Sep 30, 2015

    @ncw
    Member

    Is there a standard for .md5 files?

    rclone could potentially create it and or update it too so it would act like a cache.

    I'd probably say this should be accessed with a command line flag --md5-file or something like that. Though you might want a file both for the receiving and sending remotes!

    Probably if you passed an --md5-file then it should default to a --checksum sync.

    I like the idea.

    We should probably explore what the user interface would look like first before diving into the code - that would help clarify our thinking on exactly what the feature does.

  2. klauspost commented on Sep 30, 2015

    @klauspost
    ContributorAuthor

    It is pretty stable format.

    Sample:

    5e2eb149b6d704dcb46d685d60dbe0a9 *IMAG0013.jpg

    There can be different delimiters, " |", " *", " ". The path can also be included.

    An md5 sum file can contain md5 sums for one or several files, so a file can contain md5 sums for all files on a folder, so we cannot assume any names for the files.

    My implementation thoughts are like this. First time the fs.Md5sum() is called it, it reads the same directory as the file, and filters out the md5 sums. If the filename matches, the precalculated md5 will be used if modtime is before modtime of the md5 file.

    As for commandline options, I though that only creation would require a special flag, since--checksum is off my default anyway.

  3. ncw commented on Oct 1, 2015

    @ncw
    Member

    I don't really like the magic behaviour of adding stuff to fs.Md5sum. I'd much prefer the user to have to explicitly state they want this behaviour.

    I was thinking that there would be only one md5sums file rather than lots though, but maybe lots is OK too.

    I can see something like that working well with the local Fs

    • have an md5sum file with the md5sums for the whole tree in
    • rclone uses it as a cache for reading/caching md5sums

    I've shied away from storing metadata on the remote fs that don't support things in the past as it is a hard problem keeping it up to date especially if it is being updated from two places at once. So I don't think I'm in favour of doing this except on the local Fs.

    I think we should think clearly about what problem we are trying to solve? Is it

    1. saving the user time by caching md5s on the local Fs
    2. using pre-caclulated md5s whenever possible
    3. To work around limitations of remote FS which can't store MD5SUMs
    4. is useful, though an MD5SUMs file isn't ideal as it doesn't have the mod time of each file in it - a json file with modtime and md5sum would tell you on a per file basis whether you needed to update the md5sum or not. Using a .md5 file per file might work for some things (like an archive of big files).
    5. I'm not so sure about - how common are .md5 files?
    6. I'm probably not in favour of since the synchronisation problems where people use it from two places are quite hard. Though they become much easier if we are thinging of an .md5 file per file.

    What do you think?

  4. self-assigned this
    on Oct 6, 2015
  5. michaelthwaite commented on Nov 18, 2015

    @michaelthwaite

    I'd add that the common local md5 cache file would need to include the last modified timestamp of the file so, the checker can scan the md5 file, if the md5 matches, it then checks the modified data against the actual file, if it matches, all good and equal, if different, initiate a new md5 calculation on the file and probably assume that the file has indeed changed.

  6. klauspost commented on Nov 23, 2015

    @klauspost
    ContributorAuthor

    @ncw - it is meant as a local option to make it possible to get md5 matching without needing to do a complete file scan on every sync. Syncing that would make it feasible to sync many gigabytes of data quickly with md5 matching.

    For the first implementation the idea was only to enable reading md5sum files. That way people can use their favorite tool to create them. Maybe rclone at some point should offer updating them, or have its own format.

    My initial through was that it should be opt-in to use md5-files.

    @michaelthwaite My proprosal was to use the existing md5sum format. This format unfortunately doesn't include timestamps. However, checking modification time on both files should give a fairly reliable idea if the md5sum is current.

  7. michaelthwaite commented on Nov 23, 2015

    @michaelthwaite

    I'm guessing that means an individual md5 file for each tracked file then? Comparing the local file with the local md5 file. If you meant checking against the remote file, that's the one with the problem on ACD - no modified time.

  8. added this to the milestone on Jul 15, 2016
  9. ivandeex commented on Sep 18, 2019

    @ivandeex
    Member

    All modern Linuxes have two commands: md5sum and sha1sum. Their syntax is similar. You can manually run md5sum filename and watch hashsum in the output. In a batch scenario they are used like this:

    sha1sum /path/to/file*mask > ./hashsums.sha1
    sha1sum -c ./hashsums.sha1 # prints OK or ERROR beside all file names
    

    Hash file syntax is straightforward and simple to parse (well, sometimes filename field can be preceded with asterisk, which can be simply ignored). Here is two examples:
    md5.txt
    sha1.txt
    Someone above #157 (comment) mentioned timestamps. They are irrelevant here. Hash files are all about hashsums.

    Today rclone has everything to realize this scenario except for -c checkfile (--checkfile /path/to/hash.txt) option in its rclone md5sum and rclone sha1sum commands.

    Example scenario: user runs rclone md5sum remote:path -c summary.md5, rclone takes paths from summary.md5 one by one and joins them with path on command line, then compares sums from the checkfile against sums reported by backend. In addition to OK/ERROR statuses rclone will have UNKNOWN if a sum of a file from backend is empty or unsupported. Return status can be 0 (all OK), 1 (some ERRORs), or 2 (some UNKNOWNs, no ERRORs).

    @ncw This function is very important, moreover it's easy to impelement today as everything is in place (still "help wanted"? ;) ).

  10. ncw commented on Sep 18, 2019

    @ncw
    Member

    This function is very important, moreover it's easy to implement today as everything is in place (still "help wanted"? ;) ).

    Very much so! Want to have a go? If so please do :-)

    So implementing this flag.

    -c, --check          read MD5 sums from the FILEs and check them
    

    Unfortunately -c will conflict with the global flag, so it will have to be --check.

    This could be added to all the *sum commands

      dbhashsum       Produces a Dropbox hash file for all the objects in the path.
      hashsum         Produces an hashsum file for all the objects in the path.
      md5sum          Produces an md5sum file for all the objects in the path.
      sha1sum         Produces an sha1sum file for all the objects in the path.
    
    

    (Maybe we should get rid of dbhashsum since it is part of hashsum and I can't imagine anyone uses it!)

  11. ivandeex commented on Sep 18, 2019

    @ivandeex
    Member

    Ok, will submit PR.

  12. 13 remaining items

  13. added this to the v1.55 milestone on Feb 13, 2021
  14. ivandeex commented on Feb 15, 2021

    @ivandeex
    Member

    #1005 mentions that SUM file support can be added as -c flag to the rclone Xsum family of commands.

    what md5sum -c does is read the file created by md5sum and checks it against the filesystem.
    It is a nice feature and it would be nice for rclone md5sum. It is, as you said, very similar to rclone check but it is useful for detecting bitrot

    cc @ncw

  15. ivandeex commented on Feb 15, 2021

    @ivandeex
    Member

    I think that the logic of check differs significantly from a check with SUM file.
    Current check can have either single files or directories as its first and second arguments.
    A check with a SUM file should always have a file (local or remote or even stdin) in special format as its first argument.
    I conclude that the new command should deviate from the unix md5sum -c syntax but rather be a new verb like rclone checkfile <SUMFILE> <FILESORDIR>. (The verb is tentative, please propose you variants)
    Thoughts?

    EDIT: check is internally based on the march engine. The new command will be based on walk.

  16. modified the milestones: v1.55, v1.56 on Mar 16, 2021
  17. modified the milestones: v1.56, v1.57 on May 16, 2021
  18. ivandeex commented on May 24, 2021

    @ivandeex
    Member

    @ncw @klauspost

    I have submitted #5352 which adds support for SUM files in the form of explicit check command (think md5sum command extended for clouds, see scenario above).

    Hence the question: Is still viable the idea of using SUM files as a hashsum store transparently integrated into rclone fs.Hash internals?
    If yes then let's make title of this request more concrete and discuss the design again.

    By the way, I agree with Nick's arguments against it and propose a design where SUM files can be used to "warm up" hashsum cache but will not be "attached" to it. Please take a look at #949 (comment) !

    For the time being I'm detaching my patch #5352 from this request.

    from comment above:

    My implementation thoughts are like this. First time the fs.Md5sum() is called it, it reads the same directory as the file, and filters out the md5 sums. If the filename matches, the precalculated md5 will be used if modtime is before modtime of the md5 file.

    As for commandline options, I though that only creation would require a special flag, since--checksum is off my default anyway.

  19. ivandeex commented on Sep 9, 2021

    @ivandeex
    Member

    @ncw @klauspost
    Please review whether #5587 satisfies your requirements (especially sticky import option)

  20. modified the milestones: v1.57, v1.58 on Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions