From 736f6665f74ecea2280e1f2e36c6fdd9cf1a7483 Mon Sep 17 00:00:00 2001 From: suhas1104 Date: Sun, 7 Jul 2024 16:53:13 +0530 Subject: [PATCH] fix: google drive, authorize instead of throwing error and return text instead of blob from drive file --- src/main/application/sync/gdrive/drive.js | 2 +- src/main/application/sync/index.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/application/sync/gdrive/drive.js b/src/main/application/sync/gdrive/drive.js index 1f230d75..2fd73479 100644 --- a/src/main/application/sync/gdrive/drive.js +++ b/src/main/application/sync/gdrive/drive.js @@ -10,7 +10,7 @@ export default class Drive { async readFile(id) { const { data } = await this.drive.files.get({ fileId: id, alt: 'media' }) - return data + return data.text() } async updateFile(id, content) { diff --git a/src/main/application/sync/index.js b/src/main/application/sync/index.js index 6b9d984d..e6432904 100644 --- a/src/main/application/sync/index.js +++ b/src/main/application/sync/index.js @@ -2,7 +2,6 @@ import GDrive from './gdrive' import { mergeData } from './base/merge' const NO_INTERNET_CONNECTION = 'Swifty seems to be offline' -const NOT_CONFIGURED = 'Sync is not configured' const FAILED_TO_FIND_REMOTE_VAULT = 'Failed to find remote vault file' const FAILED_TO_CREATE_REMOTE_VAULT = 'Failed to create remote vault file' const FAILED_TO_READ_REMOTE_VAULT = 'Failed to read remote vault file' @@ -19,7 +18,9 @@ export default class Sync { } async perform() { - if (!this.isConfigured()) throw Error(NOT_CONFIGURED) + if (!this.isConfigured()) { + this.provider.setup() + } if (!(await this.remoteVaultExists())) { await this.createRemoteVault()