-
Notifications
You must be signed in to change notification settings - Fork 1
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
Listen to federated share accept event #131
Conversation
DescriptionListen to the accept event triggered for the federated share. Prior to this change the events were not listened hence no background jobs for the same were triggered. Hence the share data was not updated in the search. With this change the event is listened and the share user is added to the background job to update the content. By the time the event is listened the view of the user is not udpated with the accepted share. It happens when the share is accepted and the dav request is triggered. Once the dav request is tirggered we get sufficient time to execute the background job. IssueTest done
|
Codecov Report
@@ Coverage Diff @@
## release-1.0.0 #131 +/- ##
===================================================
+ Coverage 19.32% 19.59% +0.26%
+ Complexity 273 271 -2
===================================================
Files 24 24
Lines 1190 1230 +40
===================================================
+ Hits 230 241 +11
- Misses 960 989 +29
Continue to review full report at Codecov.
|
Tested and works 👍 |
lib/Hooks/Files.php
Outdated
* @param AcceptShare $acceptShare | ||
*/ | ||
public static function federatedShareUpdate(AcceptShare $acceptShare) { | ||
$share = $acceptShare->getShare(); |
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.
Why don't we use the status mapper here?
Please use the same logic like in the contentChanged method.
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.
While looking into the issue, my first thought was to proceed using logic like contentChanged
method. But then I found an issue with accessing nodes like for example \OC::$server->getUserFolder($share['user'])->get($share['name']). And I found that the node was not there. And then I found that a PROPFIND request is made for the user, after the share is accepted and then the nodes are available. Hence I thought we can add the background job for the user, instead of using the logic of contentChanged
. Let me know if this makes sense? @micbar
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.
The propfind request is triggered from https://github.com/owncloud/core/blob/master/core/js/files/client.js#L481
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.
So we depend on the webUI making the propfind before the cronjob runs? This is ugly.
@VicDeo Any Ideas?
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.
By design federated shares are neither scanned nor updated before user browses inside due to performance reasons.
That's why we added owncloud/core#34933 to sync them manually by cron.
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 have updated the PR with trashbin and version restore.
f7152d5
to
8f61a4f
Compare
For the trashbin and version hooks, I'd create different functions. There is also common functionality that can be reused in the From what I see, the What we get with these changes is a more streamlined flow. I expect less conditions to check, which leads to less unittests to do in order to cover all scenarios.
This is something we can't guarantee, so we musn't rely on that. |
2108cab
to
eed7b79
Compare
Updated the PR. |
lib/Hooks/Files.php
Outdated
* update to have the federated share added. | ||
*/ | ||
\OC_Util::tearDownFS(); | ||
\OC_Util::setupFS($share['user']); |
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.
Doble-check FS operations after this hook is run are executed using the previous user, not the one shared. We might need to restore the previous user.
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.
Its run against the recipient of the fed share, and its not done against the sender of the share.
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 it's better to include a comment.
Normally, you'd use \OC_Util::setupFS()
to setup the FS for the user in the session, and \OC_Util::setupFS($user)
if you need to explicitly setup the FS for a different user. At this point in the code, we might assume that we have the FS for the session user available, so it's fine to tearDown the FS.
Now, if we use \OC_Util::setupFS($share['user'])
, I assume that $share['user']
might not be the user in the session but a different user. If this is the case, I think we should restore the previous user.
We have to assume this callback won't be last to access to the FS. If after this callback is executed there are more calls to the FS, these calls will be run against the $share['user']
's FS, which as said, it could be a different user.
lib/Hooks/Files.php
Outdated
return; | ||
} | ||
|
||
public static function processNode($node, $userIdReceiver = null) { |
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.
Why the $userIdReceiver
can be null? or, why the $userIdReceiver
is needed?
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.
Updated the method. Now it accepts userId. There is a check which I have made for @
in the code.
35180f4
to
5051a76
Compare
5051a76
to
5eb28e4
Compare
Listen to the federated share accept event, trashbin restore event and file version restore event and process the event to add it to the background job. Signed-off-by: Sujith H <sharidasan@owncloud.com>
5eb28e4
to
16a88cc
Compare
lib/Hooks/Files.php
Outdated
* update to have the federated share added. | ||
*/ | ||
\OC_Util::tearDownFS(); | ||
\OC_Util::setupFS($share['user']); |
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 it's better to include a comment.
Normally, you'd use \OC_Util::setupFS()
to setup the FS for the user in the session, and \OC_Util::setupFS($user)
if you need to explicitly setup the FS for a different user. At this point in the code, we might assume that we have the FS for the session user available, so it's fine to tearDown the FS.
Now, if we use \OC_Util::setupFS($share['user'])
, I assume that $share['user']
might not be the user in the session but a different user. If this is the case, I think we should restore the previous user.
We have to assume this callback won't be last to access to the FS. If after this callback is executed there are more calls to the FS, these calls will be run against the $share['user']
's FS, which as said, it could be a different user.
16a88cc
to
41f726b
Compare
Regarding #131 (comment) I have updated the |
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.
code looks good
Not sure why codecov is responding. |
Listen to the federated share accept event
and add the accepted share to the background
job.
Signed-off-by: Sujith H sharidasan@owncloud.com