Skip to content

Commit

Permalink
fix(GoogleDrive): Try to delete superfluous files
Browse files Browse the repository at this point in the history
see #1652

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Oct 6, 2024
1 parent 2abad62 commit f7bc4ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib/adapters/GoogleDrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,18 @@ export default class GoogleDriveAdapter extends CachingAdapter {

this.accessToken = await this.getAccessToken(this.server.refreshToken)

const fileList = await this.listFiles(`name = '${this.server.bookmark_file}'`, 10)
const fileList = await this.listFiles(`name = '${this.server.bookmark_file}'`, 100)
const file = fileList.files.filter(file => !file.trashed)[0]

const filesToDelete = fileList.slice(1)
for (const fileToDelete of filesToDelete) {
try {
await this.deleteFile(fileToDelete.id)
} catch (e) {
Logger.log('Failed to delete superfluous file: ' + e.message)
}
}

if (file) {
this.fileId = file.id
if (forceLock) {
Expand Down

0 comments on commit f7bc4ed

Please sign in to comment.