Skip to content

Commit

Permalink
fix(GoogleDrive): Sort files by modified date
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Sep 10, 2024
1 parent 34369ee commit 837d73f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/adapters/GoogleDrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -404,8 +404,8 @@ export default class GoogleDriveAdapter extends CachingAdapter {
}
}

async listFiles(query: string) : Promise<any> {
const res = await this.request('GET', this.getUrl() + '/files?corpora=user&q=' + encodeURIComponent(query))
async listFiles(query: string, limit = 1) : Promise<any> {
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()
}

Expand Down

0 comments on commit 837d73f

Please sign in to comment.