Skip to content
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

Support multiple scopes in DAV search #44858

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

artonge
Copy link
Contributor

@artonge artonge commented Apr 16, 2024

Instead of making the search on the targeted folders, the current approach does it on the user's root folder, with some extra conditions applied on the path.

This allows the following scope in WebDAV SEARCH requests:

<d:from>
	<d:scope>
		<d:href>/files/user1/a</d:href>
		<d:depth>infinity</d:depth>
	</d:scope>
	<d:scope>
		<d:href>/files/user1/b</d:href>
		<d:depth>infinity</d:depth>
	</d:scope>
</d:from>

This can be tested with the following PR in Photos: nextcloud/photos#2426
With that PR, the SQL request will look like that:

SELECT
	[...]
FROM
	[...]
WHERE
	[...]
	AND (
		path COLLATE utf8mb4_general_ci LIKE "files/a/%"    -- <-- ADDED CONDITION
		OR path COLLATE utf8mb4_general_ci LIKE "files/b/%" -- <-- ADDED CONDITION
	)
	AND (
		storage = 1
		AND (
			path = "files"
			OR path LIKE "files/%"
		)
	)
ORDER BY
	[...]
LIMIT
	[...]

@artonge artonge force-pushed the artonge/feat/support_multiple_scope_in_dav_search branch from 3cba742 to 91e6cdd Compare April 16, 2024 15:03
Copy link
Member

@icewind1991 icewind1991 left a comment

Choose a reason for hiding this comment

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

If there is only a single folder, doing the search on the folder is more efficient as it can filter down the storages it searches in

apps/dav/lib/Files/FileSearchBackend.php Outdated Show resolved Hide resolved
@artonge artonge force-pushed the artonge/feat/support_multiple_scope_in_dav_search branch from e3a9de0 to 817ac06 Compare April 16, 2024 16:56
@artonge artonge force-pushed the artonge/feat/support_multiple_scope_in_dav_search branch from 0e6b256 to 8709037 Compare April 17, 2024 07:49
@artonge artonge force-pushed the artonge/feat/support_multiple_scope_in_dav_search branch 2 times, most recently from 3c42472 to 784e43b Compare April 17, 2024 09:47
apps/dav/lib/Files/FileSearchBackend.php Dismissed Show dismissed Hide dismissed
apps/dav/lib/Files/FileSearchBackend.php Fixed Show fixed Hide fixed
apps/dav/lib/Files/FileSearchBackend.php Fixed Show fixed Hide fixed
apps/dav/lib/Files/FileSearchBackend.php Fixed Show fixed Hide fixed
apps/dav/lib/Files/FileSearchBackend.php Fixed Show fixed Hide fixed
apps/dav/lib/Files/FileSearchBackend.php Fixed Show fixed Hide fixed
Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge force-pushed the artonge/feat/support_multiple_scope_in_dav_search branch from 784e43b to ac0acfb Compare April 17, 2024 10:33
Copy link
Contributor

@emoral435 emoral435 left a comment

Choose a reason for hiding this comment

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

This LGTM. In terms of optimization, I am generally unknowledgeable here, but the code logic makes sense :)

@artonge artonge merged commit 097f04c into master Apr 22, 2024
157 checks passed
@artonge artonge deleted the artonge/feat/support_multiple_scope_in_dav_search branch April 22, 2024 15:24
@artonge
Copy link
Contributor Author

artonge commented Apr 22, 2024

/backport to stable29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement feature: dav feature: files php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants