You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
saving the user time by caching md5s on the local Fs
using pre-caclulated md5s whenever possible
To work around limitations of remote FS which can't store MD5SUMs
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).
I'm not so sure about - how common are .md5 files?
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.
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.
@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.
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.
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"? ;) ).
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!)
#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
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.
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.
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.
Activity
ncw commentedon Sep 30, 2015
Is there a standard for
.md5files?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-fileor something like that. Though you might want a file both for the receiving and sending remotes!Probably if you passed an
--md5-filethen it should default to a--checksumsync.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.
klauspost commentedon Sep 30, 2015
It is pretty stable format.
Sample:
5e2eb149b6d704dcb46d685d60dbe0a9 *IMAG0013.jpgThere 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
--checksumis off my default anyway.ncw commentedon Oct 1, 2015
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
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
What do you think?
michaelthwaite commentedon Nov 18, 2015
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.
klauspost commentedon Nov 23, 2015
@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.
michaelthwaite commentedon Nov 23, 2015
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.
ivandeex commentedon Sep 18, 2019
All modern Linuxes have two commands:
md5sumandsha1sum. Their syntax is similar. You can manually runmd5sum filenameand watch hashsum in the output. In a batch scenario they are used like this: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 itsrclone md5sumandrclone sha1sumcommands.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 haveUNKNOWNif 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"? ;) ).
ncw commentedon Sep 18, 2019
Very much so! Want to have a go? If so please do :-)
So implementing this flag.
Unfortunately
-cwill conflict with the global flag, so it will have to be--check.This could be added to all the *sum commands
(Maybe we should get rid of dbhashsum since it is part of hashsum and I can't imagine anyone uses it!)
ivandeex commentedon Sep 18, 2019
Ok, will submit PR.
13 remaining items
ivandeex commentedon Feb 15, 2021
#1005 mentions that
SUMfile support can be added as-cflag to therclone Xsumfamily of commands.cc @ncw
ivandeex commentedon Feb 15, 2021
I think that the logic of
checkdiffers significantly from a check with SUM file.Current
checkcan 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 -csyntax but rather be a new verb likerclone checkfile <SUMFILE> <FILESORDIR>. (The verb is tentative, please propose you variants)Thoughts?
EDIT:
checkis internally based on themarchengine. The new command will be based onwalk.ivandeex commentedon May 24, 2021
@ncw @klauspost
I have submitted #5352 which adds support for SUM files in the form of explicit check command (think
md5sumcommand 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.Hashinternals?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:
ivandeex commentedon Sep 9, 2021
@ncw @klauspost
Please review whether #5587 satisfies your requirements (especially
sticky importoption)