Skip to content

Commit 1627e18

Browse files
authored
Merge pull request #1948 from floccusaddon/fix/acknowlegde-abuse
fix(GoogleDrive): Acknowlege abuse
2 parents 4c83c7e + e438477 commit 1627e18

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/lib/adapters/GoogleDrive.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,18 @@ export default class GoogleDriveAdapter extends CachingAdapter {
411411
throw new NetworkError()
412412
}
413413

414-
if (res.status === 401 || res.status === 403) {
415-
Logger.log('Failed to authenticate to Google API: ' + res.data)
414+
if (res.status === 401) {
415+
Logger.log('Failed to authenticate to Google API: ' + JSON.stringify(res.data))
416416
throw new AuthenticationError()
417417
}
418418

419+
if (res.status === 403) {
420+
Logger.log('Google API error: ' + JSON.stringify(res.data))
421+
throw new HttpError(res.status, method)
422+
}
423+
419424
if (res.status >= 500) {
425+
Logger.log('Google API error: ' + JSON.stringify(res.data))
420426
throw new HttpError(res.status, method)
421427
}
422428

@@ -438,7 +444,8 @@ export default class GoogleDriveAdapter extends CachingAdapter {
438444
}
439445

440446
async downloadFile(id: string): Promise<string> {
441-
const res = await this.request('GET', this.getUrl() + '/files/' + id + '?alt=media')
447+
// We acknowledge abuse so that Google Drive will give us the file contents even if it thinks it's a virus.
448+
const res = await this.request('GET', this.getUrl() + '/files/' + id + '?alt=media' + '&acknowledgeAbuse=true')
442449
return res.text()
443450
}
444451

0 commit comments

Comments
 (0)