-
Notifications
You must be signed in to change notification settings - Fork 7
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
Check if user can update node #286
base: master
Are you sure you want to change the base?
Check if user can update node #286
Conversation
Thanks for opening this PR. I like the idea of using a fallback user in case the original user doesn't have the proper permissions to overwrite the file. Although I'd prefer to not pick any random user, this could lead to confusion. Maybe let's do some testing again with To answer your question: the implementation for creating a new file version is needed since it ensures that we're not stuck in an endless loop. Also it covers the case where a new file is created instead of creating a new file version (for example when processing jpg to pdf). |
I started with getOwner and failed with groupfolders (enabled ACL with restriction to modify). The user provided by getOwner may not have the necessary rights to modify the file. To minimize this risk, it could be a two stage fallback.
|
I'm still not happy with picking a random user tbh Option 1: we need to introduce a new setting "fallback user", which is globally applied and can be only set by the admin |
I haven't had Option 2 in mind yet. Could be a good alternative. Must it be option 1 or 2? I could imagine that each approach has it's advantages and disadvantages so that it may depend on the specific use case which one makes more sense. If you really feel unhappy with this forced versioning (random user) because of potential confusion, it could be helpful to provide some clarity via the label of the current version. Instead of just adding "Before OCR", it could be an addition like "Before OCR (OCR will be done with random user)". |
To keep things simple I would aim for appending a suffix to the file. Otherwise features like for example "notifications" (which are bound to a user) would need to be reworked as well. Could be an option for the future but for now I'd go with the suffix approach. @XueSheng-GIT would you feel comfortable to implement this? |
@R0Wi happy new year and sorry for replying late. I'll try to have a look this weekend. |
I had a quick look at how to add the suffix (e.g. '_OCR') in case the file cannot be updated by user. My initial idea was to do it in the same way as images are handled right now (because it should be at least a similar situation). workflow_ocr/lib/Service/OcrService.php Lines 323 to 325 in 3a623a0
Thus, I just wanted to define
But then the workflow ended up in an endless loop because the newly created file triggers the workflow again. On the first view, I'm not sure how to prevent this endless loop because the current approach seems to require the workflow_ocr/lib/Service/OcrService.php Lines 251 to 272 in 3a623a0
@R0Wi: Is there a reason that workflow_ocr currently does not handle this self-trigger in case of image ocr? Or does |
@XueSheng-GIT indeed you're right. This wasn't the intended behavior. Probably no one noticed so far since most of the usecases will handle I guess you're right, maybe |
...and add suffix '_OCR' to processed file if not. Signed-off-by: XueSheng-GIT <[email protected]>
6643768
to
d7ea3f9
Compare
I've updated If update permissions for the processed file are missing, the suffix '_OCR' is now added. I've also done some testing with 'Keep original file version' and 'Keep original file modification date'. Everything seems to work well so far. I've partly updated the unit tests. But at least the following must still be updated to reflect the change from @R0Wi would be great if you could have a look at this updated pull and add your comments/changes to it. |
Sure @XueSheng-GIT, thanks for your effort! The solution sounds good to me, I will try to have a closer look as soon as time permits 😄 |
...and change to an alternative user if not (fixes ocr for filedrop and groupfolder acl).
@R0Wi This is just a rough proof of concept to fix #273
In comparison to the discussion at #110 (#116) this approach does first check whether the current user has the permissions to update the node. If not, an alternative user is chosen (but not owner, because this may fail for groupfolders).
This draft does not include a setting, test or further documentation. I'm also wondering whether the manual implementation for
createNewFileVersion
is really required.workflow_ocr/lib/Service/OcrService.php
Line 163 in 56be914
Wouldn't
$node->putContent
be enough?https://github.com/nextcloud/server/blob/2651d4964ec26696b5f8b1f5db48588a5d09ab01/lib/private/Files/Node/File.php#L49