server icon indicating copy to clipboard operation
server copied to clipboard

Need ctime of files after uploads

Open nickvergessen opened this issue 9 years ago • 65 comments

Ref https://github.com/nextcloud/files_retention/issues/23

Steps

  1. Set up retention to delete files after 14 days.
  2. Sync or upload a file from last year
  3. Run retention cron job

Expected

The file remains on the instance for 14 days

Actually

The file is immediately deleted, because the mtime of the file is 2016.

Problem

The problem is that since some time we use the original mtime of the file when writing the entry into the database instead of "current time". I don't know when that changed, but it's a bit annoying. Same happens with the "recent files" filter. It will not list such files, although you just uploaded them.

So we need some kind of timestamp when the file was first seen/discovered by nextcloud.

@icewind1991 you have any idea why and when this was changed? Also cc @rullzer for the client, @MorrisJobke for the customer related issue and @schiessle as per yesterday.

nickvergessen avatar Feb 22 '17 08:02 nickvergessen

Wow, huge problem.

KB7777 avatar Feb 22 '17 09:02 KB7777

Maybe storage_mtime

icewind1991 avatar Feb 22 '17 13:02 icewind1991

Unfortunately, no. The column storage_mtime contains the same value as mtime.

After an upload over the web gui the original (old) mtime is set too.

OS: Windows 10 Browser: Firefox 51.0.1 (32-Bit) Nextcloud: 11.0.1

js94x avatar Feb 22 '17 15:02 js94x

The client does this by design. Because if you edit something while you have no connection you don't want to see a changed time on the web wich differes (also you will most likely redownload the file then).

From my POV keeping the time of the file is correct. We should just also keep track of the uploaded time.

rullzer avatar Feb 28 '17 11:02 rullzer

https://github.com/nextcloud/server/pull/3822 mostly fixes this imo

icewind1991 avatar Mar 13 '17 14:03 icewind1991

Well it doesn't really help with the retention app, the behaviour is still "undesired/unintentional".

nickvergessen avatar Mar 13 '17 14:03 nickvergessen

I would argue that with retention you do want the original mtime from the sync client.

If retention is set to 14 days, I expect it to trigger 14 days after I create the file, regardless of the fact that the client was offline for a week.

icewind1991 avatar Mar 13 '17 15:03 icewind1991

Well but when you created the file four weeks ago and just put it into the sync folder just now. You don't want it to be deleted in the night when retention triggers, but 2 weeks after upload?

nickvergessen avatar Mar 13 '17 15:03 nickvergessen

Hi,

we facing the same issue. The uploads should get automatically deleted after 14 days after upload. But some of our users reported that their files were dropped much earlier than expected. After some tests and researches we found that nextcloud triggers on the mtime instead of the upload time.

Hopefully it will be fixed soon because this is a showstopper for our planned rollout.

rapITler avatar Apr 25 '17 10:04 rapITler

We really need to look into this.

nickvergessen avatar Apr 26 '17 08:04 nickvergessen

I´ve seen that the milestone was modified from 12 to 13 a month ago. Is there already a commit which changes the behavior with ctime?

js94x avatar Jun 01 '17 08:06 js94x

Damn really bad news for us! We postponed the rollout in our company to wait on NC12 only for that fix :(.

rapITler avatar Jun 01 '17 10:06 rapITler

Any progress on that one?

maxmeyer avatar Oct 16 '17 05:10 maxmeyer

Any progress on that one?

marinofaggiana avatar Mar 14 '18 12:03 marinofaggiana

@rapITler and others: if this is a issue for an enterprise PoC/deployment, contact our sales team, we can help either find an alternative solution or speed up fixing this.

jospoortvliet avatar Mar 14 '18 12:03 jospoortvliet

@icewind1991 Mind to have a look into collecting the cdate as well?

MorrisJobke avatar Mar 14 '18 13:03 MorrisJobke

ref https://github.com/icewind1991/SearchDAV/issues/3

MorrisJobke avatar Mar 14 '18 13:03 MorrisJobke

The trouble here is that in order to collect it we'd need to extend the filecache table.

What we could do:

  1. Add a new column ctime and make it null by default
  2. Add the logic to store ctime
  3. When retrieving a file if the ctime is null set it to the value of mtime

This should slowly make sure it is set for all elements. However keep in mind that adding a (even nullable) column can take significant time on certain setups.

Of course we could also add an extra occ command that does this automatically. But I would not run this in a repair step by default. It could take ages.

rullzer avatar Mar 14 '18 13:03 rullzer

Adding the column in an occ command is only possible if done beforehand

icewind1991 avatar Mar 14 '18 14:03 icewind1991

sure. I meant the copying of the mtime to the ctime ;)

rullzer avatar Mar 14 '18 14:03 rullzer