nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.49k stars 4.08k forks source link

eTag for metadata changes #8477

Open tobiasKaminsky opened 6 years ago

tobiasKaminsky commented 6 years ago

Updated version:

Provide an eTag for metadata changes (favorite, share, note, etc). Currently clients (Android / iOS) check for changed eTag when entering a folder. If this is the same with stored database no real propfind to list folder content is needed. However if e.g. a new sharee was added, we still need to retrieve it. Therefore we check every time(!) /ocs/v2.php/apps/files_sharing/api/v1/shares

This has multiple drawbacks


On next android version we wanted to rely on changed eTags when syncing a folder:

The problem now is that with this approach we do not get info about favorited/unfavorited folders. (encrypted/not encrypted I have not checked yet).

In my opinion at least the parent folder should then have a changed eTag to reflect that something has changed.

@skjnldsv @icewind1991

rullzer commented 6 years ago

Probably we should have some way to trigger a parent update on all metadata changes.

tobiasKaminsky commented 6 years ago

Any news here? This is already included in android and planned to be in next release, which is in mid march. Of course it needs a fallback for older server (if we do not backport the solution).

Changing the parent etag as @rullzer suggested should be the best. Then we know that something changed and sync child's metadata. Same for client, but as no file changed, it does not redownload anything.

rullzer commented 6 years ago

The only problem I recently thought of is that just chaning the parent etag is not enough.

Consider:

  1. userA shares a file with userB
  2. now some shared tag is added to the file by userA
  3. now we need to update 2 locations to make sure it get propogated properly everywhere

Now with two users this is fine. But now imagin sharing a file to a group of 2000 users.

tobiasKaminsky commented 6 years ago

Yeah, slight overhead ;-) But is not the same happening if you put a file into a folder which is shared with 2k users? Then also the parent eTag has to be changed and propagated to all sharees...

rullzer commented 6 years ago

Well yes but that happens only when those users request the info. Because the etag of the file changes so we can delay it until the info is requested. In this scenario we would have to do it on all changes.

Basically we would need to change the etag of the file and then it all would work. But doing that would lead to a redownload in the desktopclient.

tobiasKaminsky commented 6 years ago

Then check the modification date, it eTag changed, but mod date not, you know it is only metadata ;-) Feels very hacky -_-

tobiasKaminsky commented 6 years ago

@rullzer any news here? We want to do feature freeze / release 3.1rc1 on 22.03. and this should be in, or we would have to revert stuff on android.

rullzer commented 6 years ago

revert to old stuff. Nothing will be fixed before 22.03

tobiasKaminsky commented 6 years ago

Sad ;-) On tests I also saw that share/unshare also does not change the eTag.

tobiasKaminsky commented 6 years ago

Reminder for myself: If we have a server fix, we need a new PR for android.

tobiasKaminsky commented 6 years ago

This was scheduled for NC14, but got delayed. As mentioned on NC15 meeting, please let us do it for 15.

tobiasKaminsky commented 5 years ago

@rullzer @icewind1991 can this new eTag also change when a share is changed?

MorrisJobke commented 5 years ago

Most likely nothing that still can be done. Sorry - see my comment in #14228

tobiasKaminsky commented 5 years ago

Sad to hear, especially that this was already moved from 15 to 16… At least we have a PR now ;-)

blizzz commented 2 years ago

still an issue?

tobiasKaminsky commented 2 years ago

Yes. We would benefit quite a lot by this!

tobiasKaminsky commented 1 year ago

With https://github.com/nextcloud/android/issues/10783 we see this is one of our biggest area to improve. Most of time is spent on refreshing shares, as we have to do this all the time, as we do not know if it changed.

PVince81 commented 1 year ago

possible approaches:

1a) reuse the etag and make it change when a share, share permissions, acl, favorite, tag, etc changes

1b) like 1a but change the etag on a file also whenever its metadata changes

2) a new PROPFIND attribute "metadata-etag"

any further approaches or tweaks to the above ? @tobiasKaminsky

tobiasKaminsky commented 1 year ago

1a/b) cannot work as eTag is currently used to distinguish when to sync a file. So if eTag changes without it will cause a redownload of a downloaded file. Thus this must be a separate information.

I fear 2 is the only solution. We discussed this already quite a lot and never found another way…

PVince81 commented 1 year ago

@icewind1991 can you estimate the effort of adding an additional metadata-etag and triggering its change in various code locations, and propagating it like the initial one ?

are there any cases that we forgot to cover, like for example whether the files HPB should also expose it somehow ?

tobiasKaminsky commented 1 year ago

I remember that we even started with it at some point: https://github.com/nextcloud/server/search?q=metadata_etag

So DB is "ready" according to my limited knowledge. Which would make it easier to add, as it is then no big impact during upgrade.

starypatyk commented 1 year ago

I would like to mention that my PR #34918 is complementary to this one.

It helps in the current situation - without the metadata eTag. Will still help when the metadata eTag is implemented - in cases when the share data actually changes.