Skip to content

feature: implement advanced change detection #4810

Open

Description

@ivandeex

(Q) Currently rclone provides copy and sync commands spinning around three basic traits (hashsum, modtime, size) to detect changes using internal equal() function and its helpers.
The latter used to grow organically in response to the stream of change detection feature requests, often serving contradictory user requirements such as consistency (this PR #4011 (comment)), cost savings (see #2889 (comment)) and many others (sometimes unexplained ;)), consequently blurring the line between "bug" ang "feature".

This in turn has led to a number of change-related CLI flags (see https://rclone.org/flags), some of them having negative (no-check), conditional (x-if-y) or even double-negative (noignore) names, which interact in exotic ways with 30+ supported backends (https://rclone.org/overview#features) and their (in)ability to provide required traits.

On top of that we have filtering flags and thin difference of sync vs copy. I feel that many users have problems telling it, and documentation doesn't stress enough.

In the end we might expect that any behavior can be requested, even that that feels esoteric or illogical.
¯\_(ツ)_/¯

(A) This feature request is up to:

This seems like a big effort covering <5% of user base. OTOH there is a generalization PR #3782 (multiwrite union) that has been a success.

(spun off the #4011 (comment))

Activity

  1. ivandeex commented on Nov 26, 2020

    @ivandeex
    MemberAuthor

    NOTE: this comment was actually written by @ncw, I just copied it here from #4011 (comment)

    However it serves as a good example of uncontrolled complexity (see #4793 (comment)) of the "equal" method and around, which used to grow organically in response to the stream of change detection feature requests, often serving contradictory user requirements such as consistency (this PR #4011 (comment)), cost savings (see #2889 (comment)) and many others (sometimes unexplained ;)), blurring the line between "bug" and "feature".

    I think we could inventory the flags to see where we are at.

    However I don't want to break backwards compatibility, so if we want to change stuff then we need to do so careful!

    The equal function has been reasonably stable, I think the only thing added to it recently is --refresh-times - which is a very specialised options.

    User demand is how rclone has gained new features, though we need to be careful to push back on ones which aren't of general interest.

    This in turn has led to a number of change-related CLI flags (see https://rclone.org/flags), some of them having negative (no-check), conditional (x-if-y) or even double-negative (noignore) names, which interact in exotic ways with 30+ supported backends (https://rclone.org/overview#features) and their (in)ability to provide required traits.

    Indeed. N-flags * N-providers * N-options-per-provider is a big number.

    On top of that we have filtering flags and two unobviously different commands: sync vs copy. I feel that many users won't feel difference between them and documentation doesn't stress enough.

    More docs for sync and copy would be appreciated. The sync page has lots of warnings on now as a result of user accidents.

    In the end we might expect that any behavior can be requested, even that that feels esoteric or illogical.

    Yes, users want to get their stuff done, it is our job to keep rclone consistent!

    This probably calls for some brushing (#4793 (comment)):

    I'll just copy the comment here

    Idea: pause adding new --no-ignore-x-if-prefer-y flags for now. Add examples to docs for existing flags, they cover 95% of known use cases. For remaining 5%, create an issue to design a flag like --change-criteria +time,-size,whatever.

    I think that is a good plan to control the complexity.

    This seems like a big effort covering <5% of user base so I'm not sure.

    Making a generalised solution will mean that advanced users will have somewhere to go when then need to get stuff done, but hopefully a much smaller subset of flags will cover the main use cases (eg --checksum, --size-only).

    I like that idea. We could implement it then deprecate flags which we don't like. (You can hide flags so they still work but are hidden).

    OTOH there is a generalization PR #3782 (multiwrite union) that has been a success.

    Great idea.

    I especially like your moratorium on adding more complexity to what we've got already.

    Do you want to make an issue, then we can think about all the things which might need to be controlled?

  2. ivandeex commented on Nov 28, 2020

    @ivandeex
    MemberAuthor

    Related to #4815 (separate "sync" page in docs)

  3. ivandeex commented on Jun 11, 2021

    @ivandeex
    MemberAuthor

    Let me copy here few bits of the discussion about non-commutive flags and rclonic file comparison from #5164 (comment) and #5164 (comment) to prevent having it buried.

    Filters

    Why are the filters different? The only one of concern is --exclude-if-present which can cause issues with bi-directional sync. The following is the note I include in my readme about them:

    Filters work well since they are applied to both sides. This means that changing a filter will make the files look like it was deleted on both sides and nothing will happen.

    However, the [--exclude-if-present][eifp] filter is very dangerous if the excluded file is added on one side only after files in the directory are in sync. It will cause rclone to skip the directory on one side and appear like it was deleted.

    There are safe ways to use --exclude-if-present. For example, you can place exclude file in place on both sides before syncing. (Or placing it without adding the filter, syncing, and then adding the filter). Or, if the files have never been synced before (i.e. it's a new directory with the exclude file) then nothing bad will happen.

    This isn't a new problem in bisync from regular rclone though I do see it amplified for it.

    --exclude-if-present

    the [--exclude-if-present] filter is very dangerous if the excluded file is added on one side only after files in the directory are in sync. It will cause rclone to skip the directory on one side and appear like it was deleted.

    We have open bug reports (#4523) about this.
    We have requests (#4753, #4793) to add more non-commutive flags.
    We try (#4011, #4856) to restrain reasonably.

    rclonic file comparison

    One of the many features of rclone is that it can handle nearly all remotes the same with minor details.
    I really think it would have been better to not base this approach on an existing tool and instead design the algorithm to be "rclonic"

    The heart of rclone's omnivory change detection (runtime) lies around operations.equal, operations.checkHashes, et cetera. It's kept afloat by the astute test framework, in particular fstest.CheckListing, fstest.CheckHashes, fstest.CheckTime and [drums] retrying.

    This code is not big in terms of LOC but its perceived complexity is very high..... while users continue to request for even more change detection and filtering features :-(

    Standing on the shoulders of rsync

    when uncertain how to handle a situation, look at rsync.

    Unfortunately rclone has already diverged (#1228, #3375, #5040, #5043, docs) from rsync
    We can't easily fix that due to backwards compatibility concerns so there exists a waiting proposal (#4776) of rclone rsync besides rclone sync.

    CC @ncw @jwink @ivandeex

  4. ivandeex commented on Jun 16, 2021

    @ivandeex
    MemberAuthor

    (https://forum.rclone.org/t/syncing-timestamps-when-using-checksum/24744/12)
    Yet another mode unsupported by current set of flags:

    My use case is syncing files from source to destination. After syncing I want all files on the destination have the same contents and modification times as the source.

    In most cases, the default sync functionality will achieve this effect. However, this does not actually verify checksums for files with matching timestamps, so there's a possibility that some files will be missed.

  5. ivandeex commented on Oct 10, 2021

    @ivandeex
    MemberAuthor

    Related feature request:

    https://forum.rclone.org/t/copy-overwrite-rules-size-rule/26807

    overwrite only if the destination file is smaller than the source file.

  6. ivandeex commented on Nov 18, 2021

    @ivandeex
    MemberAuthor

    if the backend doesn't deliver a proper hash for the file, rclone should rather upload the file, assuming there is a difference, than assuming no difference

  7. ncw commented on Nov 18, 2021

    @ncw
    Member

    I'm beginning to think that if we want to support all the things users want to do with syncing we are going to need to provide a scriptable sync engine... So imagine a (insert scripting language) fragment which dealt with the sync flow.

  8. ivandeex commented on Nov 18, 2021

    @ivandeex
    MemberAuthor

    Still feels vague to me.
    Will understand when we collect enough cases, allocate time and start architecting the change detection engine.
    The 90% cases are already covered by existing flags.
    When we design engine for remaining 10%, we a free to decide that we prefer
    some NSS-like notation backed by a state machine that covers 90% of remaining 10% rather than embedding a LUA-like script.
    The unlucky 1% (10% of 10%) will be left for users to script around CLI/API. Excuse? rclone is not Santa Claus! :-)))))))

  9. ivandeex commented on Nov 18, 2021

    @ivandeex
    MemberAuthor

    I use rclone mount with a google drive backend.
    When I alter a file but leave data the same, a new revision will be generated without the patch

    advanced change engine is expected to support behavior like the patch below

    rclone/vfs/vfscache/item.go

    Lines 584 to 592 in 34c28b2

    if o == nil || !operations.Equal(ctx, cacheObj, o) {
    o, err := operations.Copy(ctx, item.c.fremote, o, name, cacheObj)
    item.mu.Lock()
    if err != nil {
    return errors.Wrap(err, "vfs cache: failed to transfer file from cache to remote")
    }
    item.o = o
    item._updateFingerprint()
    } else {

    Note that this case compares a vfs cache item against a remote object rather than two remote objects!
    If we are going to support this, the change engine must be implemented as an isolated library!

  10. ivandeex commented on Nov 19, 2021

    @ivandeex
    MemberAuthor

    We have a system where we need to copy files from an SFTP server to a Google Cloud Storage bucket. Our customers upload files into subdirectories on the SFTP server and when they're done, they upload an empty file named foobar_{timestmap}.xml. We wish to transfer the entire sub-directory from the SFTP server to GCS only once this file has been uploaded.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions