Skip to content

Allow updating file metadata without changing file etag (only change parent directory etag) #20474

Closed

Description

@ckamm

This is based on owncloud/client#3235.

Sometimes a file's mtime changes without any content change, such as when using touch (this happens in the wild to potentially big .eml files). In that case, re-uploading the file doesn't make sense. Instead, the sync client should just update the server mtime.

That file metadata change should not update the file's etag (other clients should not re-download the file), but should update the parent directory's etag (to signal that a metadata update is required).

I've tried doing this with a PROPPATCH on the getlastmodified property against 8.2.0, but the file etag changes.

Activity

  1. ogoffart commented on Nov 12, 2015

    @ogoffart

    In general, i'd say the etag should change if and only if the contents of the file changes. It should not change for metadata like mtime or permissions.
    However the etag of the parent directory recursively up to the root should change.

  2. MorrisJobke commented on Nov 12, 2015

    @MorrisJobke
    Contributor
  3. PVince81 commented on Nov 13, 2015

    @PVince81
    Contributor

    This was the expected behavior so far, so this would be a change of behavior to be discussed.

    @ckamm I'm guessing that the purpose of this change is to prevent unneeded redownload of files when they were touched.

    Does the client cache the server's mtime in its local database ? If yes, then if the behavior changes, how will the client update the local DB if the etag did not change ? Will it do a PROPFIND diff and find a different mtime ?

    also CC @rperezb for the mobile team

  4. PVince81 commented on Nov 13, 2015

    @PVince81
    Contributor

    Ah yes, the eml problem. I also had the same thoughts as @ckamm regarding touching the file.

    Please note that changing share information (permissions) will now change the etag. Permissions could be considered as metadata too. #16587.
    But that will change the etag of the parent, not of the file directly.
    Also slightly related #16589

  5. ckamm commented on Nov 13, 2015

    @ckamm
    Author

    @PVince81 Yes, we want to prevent unneeded downloads.

    I think @ogoffart put it nicely: the etag of a file should change if and only if the file contents change. If the file metadata changes, keep the file etag the same, but update the parent directories etag (recursively up to root).

    As far as I know this is how permission metadata changes work too.

  6. PVince81 commented on Nov 13, 2015

    @PVince81
    Contributor

    Sounds good

  7. PVince81 commented on Nov 13, 2015

    @PVince81
    Contributor

    @icewind1991 @DeepDiver1975 any comments on this proposal ?

  8. PVince81 commented on Nov 13, 2015

    @PVince81
    Contributor

    00002839

  9. 7 remaining items

  10. added this to the backlog milestone on Jul 25, 2016
  11. guruz commented on Jul 5, 2018

    @guruz
    Contributor

    Would be nice to get this fixed at some point™.
    owncloud/client#6629 (comment)

  12. changed the title [-]Allow updating file metadata without changing etag[/-] [+]Allow updating file metadata without changing file etag (only change parent directory etag)[/+] on Jul 5, 2018
  13. PVince81 commented on Jul 5, 2018

    @PVince81
    Contributor

    In theory, in the scenario from the first post and now that we have checksums, we could even compare the checksum and not change the etag in case the file is the same as before, at the time we'd overwrite the checksum value. Or even go further, if the announced checksum from an upload matches the current file, don't bother uploading at all and discard the data and chunk assembly.
    If the mtime changed, we'd still need to adjust it based on "OC-X-Mtime".

    Now there's still the question whether we should trust the announced checksum in case of bugs: for example if a client would send different data with the same old checksum, in which case a checksum error would be expected instead of just saying "ok, I already had the file, bye".

    Not sure if we should consider this related to the topic at hand or if it's a completely separate topic.


    Regarding the actual topic of not changing metadata, I had a look in the code and it seems we'll need a bit of refactoring and/or tweaking the Updater API signature: this writeUpdate https://github.com/owncloud/core/blob/v10.0.8/lib/private/Files/View.php#L1204 actually calls the Cache\Updater class to set the new mtime to oc_filecache, and this class also implicitly calls the etag propagator. We'd need to extend its update() method to take a parameter $parentOnly = false to tell it to only propagate to parents.

    let's go with the following approach:

    • adjust Cache\Updater::update() with extra $parentOnly = false param
    • pass along the param from View's basicOperation writeUpdate() call

    Estimate: 1-2md

    The max time is in case the tech concept is not acceptable and need to find another way around, because Cache\Updater is technically public API, so need to be careful with changing the method signatures.

    Any objections @butonic @jvillafanez to the concept ?

  14. guruz commented on Jul 9, 2018

    @guruz
    Contributor

    @PVince81 Hm I think what you are writing in your first part of the comment is a different topic. From the client side we want to use PROPPATCH. There is no "other checksum" in this case, there only is a new MTime. (And maybe an If-Match with the client perceived ETag)
    What @ckamm described in his post is a client-side decision (detecting if the contents actually updated)

    However you could still do what you described, in a multi-client or multi-user scenario it makes sense. But it's not what we from client side wanted now..

  15. stale commented on Sep 20, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

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