Skip to content

Conversation

@nfebe
Copy link
Contributor

@nfebe nfebe commented Mar 6, 2025

Description

Add share filtering to Share API

@github-project-automation github-project-automation bot moved this to 🏗️ In progress in 📁 Files team Mar 6, 2025
@nfebe nfebe marked this pull request as ready for review March 7, 2025 11:12
@nfebe nfebe requested review from a team as code owners March 7, 2025 11:12
Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need two requests to the backend, we also can just filter on the frontend

Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the filtering should be done on the frontend.
Also this breaks other API users because you introduce a new field without a default value that is the same as the current behavior.

@nfebe
Copy link
Contributor Author

nfebe commented Mar 7, 2025

Not sure we need two requests to the backend, we also can just filter on the frontend

I think having this in the API is necessary. An API that returns different types of shares should naturally support filtering by type. Beyond this specific use case, I’m actually surprised that this wasn’t already possible in the GET. It seems like a basic and useful capability.

cc: @susnux

Agreed, the filtering should be done on the frontend.
Also this breaks other API users because you introduce a new field without a default value that is the same as the current behavior.

That is not true. This change is not a breaking change. Omitting the parameter results in the current behavior, returning all shares as expected. Internal and external apps will continue to function as before.

cc: @provokateurin


Generally, this increases performance, especially for instances/users with a sizable number of shares, Splitting and parallelizing the request has clear benefits and some drawbacks and so does frontend filtering.

The new new API option/field, is a valuable addition because asides giving the client more flexibility it does not change current behavior, as long as it gets into the OpenAPI spec/admin docs I believe this has more advantages than drawbacks.

@susnux
Copy link
Contributor

susnux commented Mar 7, 2025

Generally, this increases performance, especially for instances/users with a sizable number of shares, Splitting and parallelizing the request has clear benefits and some drawbacks and so does frontend filtering.

I am not sure here.

  1. the sidebar loading will increase as the second request itself will add a delay (network)
  2. You need to setup the whole enviroment (filesystem / shares) two times as we never ask for only one of both, so this basically duplicates the request time. Meaning if in worst case there is no other php process available this now will take twice the time as before and even if handled sequentially it will double the server load.

So I do not see any benefit here as the shares are requested the same way, there is no shortcut taken while fetching the shares, only formatting them is skipped. But this means now we have two fetch all shares 2 times iterate overthem and filter them.

@nfebe nfebe force-pushed the fix/51226/show-remote-shares-as-external branch from 6339447 to cca22cb Compare March 7, 2025 16:20
@nfebe
Copy link
Contributor Author

nfebe commented Mar 7, 2025

the sidebar loading will increase as the second request itself will add a delay (network)

If making two requests results to smaller response sizes then, it is generally faster. The different components can render as the data is available.

You need to setup the whole enviroment (filesystem / shares) two times as we never ask for only one of both, so this basically duplicates the request time. Meaning if in worst case there is no other php process available this now will take twice the time as before and even if handled sequentially it will double the server load.

This is a legitimate concern, I have added a commit to avoid fetching ALL shares, as the method that does it sequentially iterates over all the providers, if we simply pass the types (providers) to this method, then it stops most of this problem.

foreach ($providers as $provider) {
if (!$this->shareManager->shareProviderExists($provider)) {
continue;
}
$providerShares =
$this->shareManager->getSharesBy($viewer, $provider, $node, $reShares, -1, 0);
$shares = array_merge($shares, $providerShares);
}

The issue of more requests -> more server load remains nonetheless this kind of filtering is usually handled at the backend and even we do not want to use it here, I still think it is essential that shares can be filtered by type.

cc: @susnux

Copy link
Contributor Author

@nfebe nfebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am aware of the missing openapi update, had some issues with composer exec generate-spec.

While the main reviews are being cleared that would be handled.

@provokateurin
Copy link
Member

I'm mostly siding with @susnux here and my previous comments were under the assumption that the providers were told which share types to query (because I didn't look at the code further).
If we really want to make some performance improvements, then the providers need to be optimized to only query the expected types.
TBH the entire system is a bit weird with fetching all shares from all provider types all the time, but at least it is consistent. We can't just randomly change this, with minimal performance reward, and possible break API consumers.

@skjnldsv skjnldsv removed their request for review March 11, 2025 10:39
@nfebe nfebe force-pushed the fix/51226/show-remote-shares-as-external branch from cca22cb to 55ae3e4 Compare March 12, 2025 23:11
@nfebe nfebe requested a review from provokateurin March 12, 2025 23:12
@nfebe
Copy link
Contributor Author

nfebe commented Mar 12, 2025

/compile

@nfebe nfebe force-pushed the fix/51226/show-remote-shares-as-external branch from 508eb9d to 7dcd393 Compare March 12, 2025 23:28
@nfebe nfebe changed the title enh: Show remote shares in external section feat(files_sharing): Add types filter to share API Apr 24, 2025
@nfebe nfebe marked this pull request as draft April 24, 2025 23:10
@nfebe nfebe removed the 3. to review Waiting for reviews label Apr 24, 2025
@nfebe
Copy link
Contributor Author

nfebe commented Apr 24, 2025

I've moved the fix to: #52423.
I'll treat this as a non-backportable addition, which also gives us more time to address any related performance issues without blocking the original fix.

nfebe added 3 commits April 25, 2025 01:13
Improve the OCS files sharing API to include a share type filter in `getShares`

Signed-off-by: nfebe <[email protected]>
With the types filter in place (1e7f53e) we should avoid,
fetching all shares.

Preventing potential N+1s

Signed-off-by: nfebe <[email protected]>
@nfebe nfebe force-pushed the fix/51226/show-remote-shares-as-external branch from 7dcd393 to 6aaba03 Compare April 24, 2025 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🏗️ In progress

Development

Successfully merging this pull request may close these issues.

4 participants