Properly expire ext storage versions#26601
Conversation
System-wide external storages have no real owner so the current user is used as owner. However when running cron.php there is no current user, so no expiry can be done. This fix adds an user argument to the expire() function to tell for which user to expire files. This information is anyway always available now through the expire command job.
|
@PVince81, thanks for your PR! By analyzing the history of the files in this pull request, we identified @MorrisJobke, @scrutinizer-auto-fixer and @bartv2 to be potential reviewers. |
|
|
||
| \OC_Util::setupFS($this->user); | ||
| Storage::expire($this->fileName); | ||
| Storage::expire($this->fileName, $this->user); |
There was a problem hiding this comment.
I find weird that you have to setup the FS for a user and then provide the same user to expire the versions. One of those shouldn't be needed from my point of view.
With the new code it's possible to setup the FS for one sure and expire versions for other... not from the command, but from other parts of the code.
There was a problem hiding this comment.
I prefer this explicit way. If we don't it means we need to find out who is the user that was currently set up and extract the name from the mount point paths... super-ugly.
Or would you prefer if we moved the setupFS into the expire function instead ?
There was a problem hiding this comment.
As long as we make clear that the "expire" function will unset the previous FS and set the new one, I think it's fine. It's acceptable from my point of view.
I don't know if it's being used outside of the CLI though.
There was a problem hiding this comment.
Ok, now I moved setupFS into the expire function.
I also removed tearDownFS because recently we added automatic tear down between background jobs (which is the other usage outside of CLI)
|
@jvillafanez second review ? |
| throw new \OC\User\NoUserException('Backends provided no user object for ' . $uid); | ||
| } | ||
|
|
||
| \OC_Util::setupFS($uid); |
There was a problem hiding this comment.
Shouldn't we tearDown the FS first? What happens if there is another FS already set up?
If the method won't re-set the previous FS after finishing the operation (which might be fine), then we should document this properly. Other users might consider that after this function is called, the FS would be the same, which isn't true right now.
There was a problem hiding this comment.
In general calling setupFS with the same user will do nothing. And calling it with another user will just add that user's FS to the existing mount points, making the new mount points available as well. This is done for sharing for example.
I don't think we should tear down here at all, especially considering that this isn't used anywhere else and is private API anyway.
This whole setupFS/tearDown FS needs to be redesigned from the ground up...
There was a problem hiding this comment.
Ok, but let's write that in the docs in order to make clear what is the expected behaviour for the function.
|
@jvillafanez done e71b59f |
|
👍 |
* Properly expire ext storage versions System-wide external storages have no real owner so the current user is used as owner. However when running cron.php there is no current user, so no expiry can be done. This fix adds an user argument to the expire() function to tell for which user to expire files. This information is anyway always available now through the expire command job. * Move version expire setupFS into the expire function * Add comment about not tearing down in version Storage::expire()
|
stable9.1: #26681 |
* Properly expire ext storage versions System-wide external storages have no real owner so the current user is used as owner. However when running cron.php there is no current user, so no expiry can be done. This fix adds an user argument to the expire() function to tell for which user to expire files. This information is anyway always available now through the expire command job. * Move version expire setupFS into the expire function * Add comment about not tearing down in version Storage::expire()
|
stable9: #26682 |
…sions [stable9] Properly expire ext storage versions (#26601)
…ersions [stable9.1] Properly expire ext storage versions (#26601)
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
System-wide external storages have no real owner so the current user is
used as owner. However when running cron.php there is no current user,
so no expiry can be done.
This fix adds an user argument to the expire() function to tell for
which user to expire files. This information is anyway always available
now through the expire command job.
Related Issue
Fixes #24161
Motivation and Context
How Has This Been Tested?
See ticket for details
Screenshots (if appropriate):
Types of changes
Checklist:
Backports
Please review @VicDeo @jvillafanez @DeepDiver1975