server icon indicating copy to clipboard operation
server copied to clipboard

Delete previews

Open charleypaulus opened this issue 3 years ago • 15 comments

Provides a new occ command to delete previews, with options:

  • to only delete previews of original files that no longer exist
  • to only delete previews of files of a specific mimetype
  • to delete previews in batches of a specified number, for database access performance purpose

Tested on NC 26, with S3 as primary object storage, and with local storage. Tested all combinations of options. Verified that previews are actually deleted from S3 storage and from filecache.

Addressing these issues (as a manual command): #26014, #20344, #18416, #35290 @szaimen, @solracsf, @arpadmuller, @skjnldsv, @SimplyCorbett, @MorrisJobke

charleypaulus avatar Nov 15 '22 20:11 charleypaulus

Seems promising. Tested also on local filesystem?

solracsf avatar Nov 15 '22 20:11 solracsf

Seems promising. Tested also on local filesystem?

Just tested it on local storage configuration. It worked as well.

charleypaulus avatar Nov 16 '22 06:11 charleypaulus

php-cs is not happy :) Autoloader too. Please run: bash build/autoloaderchecker.sh

skjnldsv avatar Nov 18 '22 13:11 skjnldsv

I tried to fix the checks as much as I could, up to the point I need help :)

  • I ran bash build/autoloaderchecker.sh. It changed 50 files, that I committed. Not sure I had to do that.
  • I installed phpcs on my laptop. Is there a specific rules file for Nextcloud that I should be using when running phpcs ?

Thanks for your help.

charleypaulus avatar Nov 19 '22 06:11 charleypaulus

I ran bash build/autoloaderchecker.sh. It changed 50 files, that I committed. Not sure I had to do that.

You can drop them, only add changes from lib/composer/composer/autoload_classmap.php and lib/composer/composer/autoload_static.php.

I installed phpcs on my laptop. Is there a specific rules file for Nextcloud that I should be using when running phpcs ?

It should automatically use the .php-cs-fixer.dist.php file.

tcitworld avatar Nov 21 '22 11:11 tcitworld

conflicts...

szaimen avatar Nov 23 '22 13:11 szaimen

I ran bash build/autoloaderchecker.sh. It changed 50 files, that I committed. Not sure I had to do that.

You can drop them, only add changes from lib/composer/composer/autoload_classmap.php and lib/composer/composer/autoload_static.php.

I installed phpcs on my laptop. Is there a specific rules file for Nextcloud that I should be using when running phpcs ?

It should automatically use the .php-cs-fixer.dist.php file.

I fixed the php-cs issue. I commited changes to lib/composer/composer/autoload_classmap.php and lib/composer/composer/autoload_static.php following a bash build/autoloaderchecker.sh. But I still get a continuous integration issue and a performance issue. I also tried to commit all autoload files (in addition to the two above), but it did not help.

charleypaulus avatar Nov 23 '22 19:11 charleypaulus

/rebase

miaulalala avatar Nov 24 '22 23:11 miaulalala

@CarlSchwan To enhance modularity, we could split your preview:reset-rendered-texts command into one command that just deletes avatars (the first part of your command), and use the command I propose here for the second part of your command.

Indeed, my proposed preview:delete command is a generalization (deleting all previews) of the second part of your command, but that can target a specific mimetype with an option, e.g. preview:delete --mimetype="text/plain".

Except of course if you have a specific use case that requires to delete both avatars and text file previews in one go.

charleypaulus avatar Dec 04 '22 11:12 charleypaulus

Why is the background job not enough? Should we fix it too?

The background job only deletes remnant previews. This manual command can be used to delete any kind of previews (all previews, remnant previews, non-remnant previews of files of a specific mimetype). I see the following use cases (not exhaustive):

  • When a user decides to specify a new preview size (with preview_max_x/y in config.php or with previewgenerator), to delete all previews before generating new sizes
  • When a user decides to limit previews to certain file types (with enabledPreviewProviders in config.php) (eg. just for pictures and no longer for text files), to delete previews that are no longer used (and save related space)
  • When a user decides to stop using previews (with enable_previews => false in config.php), to delete all previews (for space or performance issues)

charleypaulus avatar Dec 21 '22 07:12 charleypaulus

Yet another use case where we need a native Delete Preview command:

The Memories app configuration page reads:

If you already generated previews and want to regenerate, run the following (at your own risk; have backups) rm -rf <nextcloud-data-dir>/appdata_*/preview occ files:scan-app-data

This rm command won't work with an S3 storage.

Please include the command I'm proposing in this pull request.

charleypaulus avatar Oct 12 '23 04:10 charleypaulus

Hi, this PR is still active? Because i need it for fix my s3 issues 🙄

tirenucci avatar Jan 08 '24 12:01 tirenucci

up ?

tirenucci avatar Feb 01 '24 14:02 tirenucci

up ?

I hope it is still active. I've been waiting for review and approval.

I have fixed conflicts with latest master a few times. I can fix them again if I know there is an intention to include this PR.

charleypaulus avatar Feb 01 '24 14:02 charleypaulus

up ?

I hope it is still active. I've been waiting for review and approval.

I have fixed conflicts with latest master a few times. I can fix them again if I know there is an intention to include this PR.

I hope too, in the meantime I deactivate previews...

tirenucci avatar Feb 02 '24 17:02 tirenucci

@charleypaulus Please fix the conflicts in this PR, it's running a little late but hopefully this will get in for NC30

inetol avatar Aug 06 '24 17:08 inetol