chibisafe icon indicating copy to clipboard operation
chibisafe copied to clipboard

[FEATURE REQUEST] File expiration

Open TyroneSama opened this issue 9 years ago • 15 comments

It would be nice to be able to configure automatic file deletion, to use lolisafe as a temporary uploader or save on disk space.

The usual way of doing it is "delete after X days", but it could also be useful to have files delete themselves after X days of not being accessed, so that frequently accessed files aren't suddenly pulled down.

TyroneSama avatar Apr 11 '17 07:04 TyroneSama

I'm not sure I'm fond of the idea. I can see it being useful in the scenario you depicted, but it would take a revamp of the frontend prompting the user if the files should expire or not. I'll think about it and let you know in a few days.

Thanks for the suggestion!

Pitu avatar Apr 12 '17 19:04 Pitu

it would benefit safe.moe extremely

jithatsonei avatar Apr 12 '17 21:04 jithatsonei

who dat

Pitu avatar Apr 12 '17 22:04 Pitu

I wasn't really thinking of a per-file option, actually, though that could be useful. I'd personally get more use out of a global setting that applies to all uploads, which at least saves you the trouble of the UI redesign.

TyroneSama avatar Apr 20 '17 11:04 TyroneSama

You can just set this up as a cron on the server itself:

@daily /usr/bin/find /full/path/to/lolisafe/uploads -type f -atime +30 -delete

This will delete all files that have not been accessed in over 30 days, not including those that are exactly 30 days.

Edit: Just realized that this would also delete thumbnail images if you don't go into the thumbnail view... would not recommend doing this ^^;

giantcow avatar Mar 26 '18 09:03 giantcow

@RyoshiKayo That wouldn't clean the database references to those files.

While it would solve the immediate issue of storage space, it is a hamfisted method.

noirscape avatar Mar 26 '18 12:03 noirscape

yeah you'd need a check script rather then trying to tie it all into one cronjob, sql will be needed to drop the data also

isnt too hard to do tbh

jithatsonei avatar Apr 01 '18 16:04 jithatsonei

This should also apply to album links

Pitu avatar Jan 05 '21 07:01 Pitu

BobbyWibowo's fork has Cloudflare purge and file expiry cleanup implemented but the fork is still on V3 so I'm not sure how well it'd be able to translate to V4

Lack of this functionality is a major blocker for my own image host to migrate to V4

https://github.com/BobbyWibowo/lolisafe/blob/safe.fiery.me/controllers/utilsController.js#L513 https://github.com/BobbyWibowo/lolisafe/blob/safe.fiery.me/controllers/utilsController.js#L622 https://github.com/BobbyWibowo/lolisafe/blob/safe.fiery.me/controllers/utilsController.js#L413

and some relevant scripts https://github.com/BobbyWibowo/lolisafe/tree/safe.fiery.me/scripts

CyberiumShadow avatar Mar 20 '21 20:03 CyberiumShadow

Definitely something to look forward to, that's super useful

Pitu avatar Mar 22 '21 00:03 Pitu

Added File Expiry with https://github.com/WeebDev/chibisafe/pull/307

Design decisions will need to be made though between:

  • Potentially leaving files behind OR
  • Much Higher Database operations OR
  • Potential files not existing for the duration of a delete when requested by a client

Have to choose which of these is the lesser evil. For most people I imagine higher db ops is fine, as it's only them or a few people using it, but for a larger host with constant file uploads / short expiry times, it would put a fair amount of load on the db.

IMO option 2 with db ops being higher is the way to go, but it's inefficient. Open to other opinions.

Can be very much extended with cache purge support, parse duration support for non "day" lengths etc. But this is a good starting point at least :)

test137E29B avatar Nov 03 '21 19:11 test137E29B