3
3
* SPDX-License-Identifier: AGPL-3.0-or-later
4
4
*/
5
5
6
- import type { INode } from '@nextcloud/files'
6
+ import type { Node } from '@nextcloud/files'
7
7
import type { ResponseDataDetailed , SearchResult } from 'webdav'
8
8
9
9
import { getCurrentUser } from '@nextcloud/auth'
@@ -17,6 +17,8 @@ export interface SearchNodesOptions {
17
17
signal ?: AbortSignal
18
18
}
19
19
20
+ export const MIN_SEARCH_LENGTH = 3
21
+
20
22
/**
21
23
* Search for nodes matching the given query.
22
24
*
@@ -25,16 +27,18 @@ export interface SearchNodesOptions {
25
27
* @param options.dir - The base directory to scope the search to
26
28
* @param options.signal - Abort signal for the request
27
29
*/
28
- export async function searchNodes ( query : string , { dir, signal } : SearchNodesOptions ) : Promise < INode [ ] > {
30
+ export async function searchNodes ( query : string , { dir, signal } : SearchNodesOptions ) : Promise < Node [ ] > {
29
31
const user = getCurrentUser ( )
30
32
if ( ! user ) {
31
33
// the search plugin only works for user roots
34
+ logger . debug ( 'No user found for search' , { query, dir } )
32
35
return [ ]
33
36
}
34
37
35
38
query = query . trim ( )
36
- if ( query . length < 3 ) {
39
+ if ( query . length < MIN_SEARCH_LENGTH ) {
37
40
// the search plugin only works with queries of at least 3 characters
41
+ logger . debug ( 'Search query too short' , { query } )
38
42
return [ ]
39
43
}
40
44
@@ -75,6 +79,7 @@ export async function searchNodes(query: string, { dir, signal }: SearchNodesOpt
75
79
76
80
// check if the request was aborted
77
81
if ( signal ?. aborted ) {
82
+ logger . debug ( 'Search request aborted' , { query, dir } )
78
83
return [ ]
79
84
}
80
85
0 commit comments