From 837d73f77538380bda6a136c35b82ef04b8cef3c Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Tue, 10 Sep 2024 11:22:48 +0200 Subject: [PATCH] fix(GoogleDrive): Sort files by modified date Signed-off-by: Marcel Klehr --- src/lib/adapters/GoogleDrive.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/adapters/GoogleDrive.ts b/src/lib/adapters/GoogleDrive.ts index dab00157f1..63572e5673 100644 --- a/src/lib/adapters/GoogleDrive.ts +++ b/src/lib/adapters/GoogleDrive.ts @@ -214,7 +214,7 @@ export default class GoogleDriveAdapter extends CachingAdapter { this.accessToken = await this.getAccessToken(this.server.refreshToken) - const fileList = await this.listFiles(`name = '${this.server.bookmark_file}'`) + const fileList = await this.listFiles(`name = '${this.server.bookmark_file}'`, 10) const file = fileList.files.filter(file => !file.trashed)[0] if (file) { this.fileId = file.id @@ -404,8 +404,8 @@ export default class GoogleDriveAdapter extends CachingAdapter { } } - async listFiles(query: string) : Promise { - const res = await this.request('GET', this.getUrl() + '/files?corpora=user&q=' + encodeURIComponent(query)) + async listFiles(query: string, limit = 1) : Promise { + const res = await this.request('GET', this.getUrl() + `/files?corpora=user&q=${encodeURIComponent(query)}&orderBy=modifiedTime%20desc&fields=files(id%2Cname%2Ctrashed)&pageSize=${limit}`) return res.json() }