-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: previews are physically deleted from disk and db in an async ma… #40045
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
💥 Acceptance tests pipeline apiProvisioningGroups-v2-mariadb10.2-php7.4 failed. The build has been cancelled. |
94f9b39
to
9c92a52
Compare
|
This comment was marked as resolved.
This comment was marked as resolved.
d8b7718
to
fda123a
Compare
Kudos, SonarCloud Quality Gate passed! |
This is docs relevant, hooking myself in for early notice |
core/Application.php
Outdated
@@ -242,5 +243,8 @@ public function __construct(array $urlParams= []) { | |||
$container->registerService('TwoFactorAuthManager', static function (SimpleContainer $c) { | |||
return $c->query('ServerContainer')->getTwoFactorAuthManager(); | |||
}); | |||
|
|||
# add preview cleanup job | |||
$container->getServer()->getJobList()->add(new PreviewCleanupJob()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any better placement?
We'll be hitting the DB on any request even if it just checks whether the job is there or not. In addition, if for whatever reason we want to remove the job, it will be added again, which might be confusing specially for support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not aware of any other way to add cron jobs ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to files app - job is added via info.xml
core/Command/Previews/Cleanup.php
Outdated
}); | ||
|
||
$output->writeln("$count orphaned previews deleted"); | ||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should return the exit code of the command, which should be 0 if it's successful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken care of
core/Command/Previews/Cleanup.php
Outdated
$progress = static function () { | ||
}; | ||
} | ||
$root = \OC::$server->getLazyRootFolder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be injected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lazy root cannot be injected
core/Command/Previews/Cleanup.php
Outdated
$lastFileId = $row['fileid']; | ||
|
||
$userFiles = $root->getUserFolder($userId); | ||
if ($userFiles->getParent()->nodeExists('thumbnails')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems better to check for the thumbnails folder directly from the root, something like $root->get("$userId/thumbnails");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the API allow to use a path like that? I am not aware of this - but happy to adopt if this works ...
core/Command/Previews/Cleanup.php
Outdated
} | ||
|
||
private function cleanFileCache($name) { | ||
$sql = "delete from `*PREFIX*filecache` where path like 'thumbnails/$name/%' or path = 'thumbnails/$name'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we guarantee somehow that we're deleting from our thumbnails directory? I mean, there could be an external storage containing paths such as "SFTP/thumbnails/plans/January", which might get accidentally deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken care of
core/Jobs/PreviewCleanupJob.php
Outdated
} | ||
|
||
public function run($arguments) { | ||
$cmd = new Cleanup(\OC::$server->getDatabaseConnection()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance to inject the service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the call nature of jobs they cannot have arguments in ctor ..... afaik ....
Any progress? would be great if it can go into 10.11 |
fda123a
to
19b4034
Compare
CI reports one error: |
Really having a hard time here to reproduce the postgres failure .... but observed it in other places: Test\Comments\ManagerTest::testDeleteReferencesOfActorWithUserManagement - core/tests/lib/Comments/ManagerTest.php Line 646 in e60f5f0
|
5e916fd
to
d93b3b1
Compare
Q: in preparation for docs: but…, what happens if you set ˋ--all chunk_size=50ˋ ? |
chunk size defined the number of files being processed in one loop chunk_size=50: run once and process 50 files |
5336c52
to
cda67af
Compare
What is the limiting factor of the loop when it runs only once? |
Additional Q:
|
the background job is added by default and suits perfect for smaller aka community installations. |
cda67af
to
ee94c75
Compare
SonarCloud Quality Gate failed. |
During writing the docs, I tried the command and an error raised:
|
Nobody said a string "chunksize=1" should be legal. Casting it to (int) does not return the integer part. It returns always 0. The syntax description is
Try |
@jnweiger is right, my command was wrong, sorry for the noise 😢 |
PR #40362 adds validation of the |
THX for the effort - but from a consistency point of view this should be added to all commands or none .... 🤷 |
Lots of occ commands validate their inputs before proceeding,
and yes, all inputs should be validated everywhere. All starfish on the beach should be saved, but saving one is better than saving none. |
…nner
ToDos
Description
All preview hooks are gone now. Previews are cleaned up on disk and db in a background job (alternative occ command)
Related Issue
How Has This Been Tested?
Scenario I
Scenario II
Scenario III
Types of changes
Checklist: