diff --git a/.gitignore b/.gitignore index ad528ab..2e00f3e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ data.json # Exclude macOS Finder (System Explorer) View States .DS_Store -pnpm* \ No newline at end of file +pnpm* +*.zip \ No newline at end of file diff --git a/actions.js b/actions.js index f03d180..60af61b 100644 --- a/actions.js +++ b/actions.js @@ -38,7 +38,6 @@ const uploadFile = async ( method: "POST", headers: { Authorization: `Bearer ${accessToken}`, - "Content-Type": "application/json", }, body: JSON.stringify({ @@ -140,7 +139,6 @@ const uploadFolder = async (accessToken, foldername, rootId = null) => { method: "POST", headers: { Authorization: `Bearer ${accessToken}`, - "Content-Type": "application/json", }, body: JSON.stringify({ @@ -169,7 +167,6 @@ const getFilesList = async (accessToken, vault) => { method: "GET", headers: { Authorization: `Bearer ${accessToken}`, - Accept: "application/json", }, }); let files = response.json.files; @@ -186,7 +183,6 @@ const getFilesList = async (accessToken, vault) => { method: "GET", headers: { Authorization: `Bearer ${accessToken}`, - Accept: "application/json", }, }); files = files.concat(response.json.files); diff --git a/main.ts b/main.ts index 629cfcb..2ea3c8c 100644 --- a/main.ts +++ b/main.ts @@ -158,7 +158,9 @@ export default class driveSyncPlugin extends Plugin { /* files created when offline are assigned a dummy fileId so the following Map keeps track of the dummy fielId to the actual fileId which is retrieved when the file is uploadedf for the first time when online */ - this.writeToVerboseLogFile("LOG: Entering completeAllPendingSyncs"); + await this.writeToVerboseLogFile( + "LOG: Entering completeAllPendingSyncs" + ); let uuidToFileIdMap = new Map(); let pendingSyncFile = this.app.vault.getAbstractFileByPath( @@ -279,7 +281,7 @@ export default class driveSyncPlugin extends Plugin { pendingSyncItems.length } changes` ); - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: completeAllPendingSyncs: Finished one operation" ); } @@ -289,22 +291,22 @@ export default class driveSyncPlugin extends Plugin { await this.writeToPendingSyncFile(); } this.completingPendingSync = false; - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); } if (pendingSyncItems.length) { new Notice("Sync complete!"); this.finalNamesForFileID.clear(); await this.writeToPendingSyncFile(); - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: completeAllPendingSyncs: Finished allpendingSyncs" ); } this.completingPendingSync = false; this.pendingSync = false; - this.refreshAll(); - this.writeToVerboseLogFile("LOG: Exited completeAllPendingSyncs"); + await this.refreshAll(); + await this.writeToVerboseLogFile("LOG: Exited completeAllPendingSyncs"); }; checkForConnectivity = async () => { @@ -312,7 +314,9 @@ export default class driveSyncPlugin extends Plugin { return; } try { - this.writeToVerboseLogFile("LOG: Entering checkForConnectivity"); + await this.writeToVerboseLogFile( + "LOG: Entering checkForConnectivity" + ); await fetch("https://www.github.com/stravo1", { mode: "no-cors", }); @@ -322,24 +326,24 @@ export default class driveSyncPlugin extends Plugin { this.connectedToInternet = true; this.checkingForConnectivity = false; } - this.completeAllPendingSyncs(); + await this.completeAllPendingSyncs(); } catch (err) { console.log("Checking for connectivity again after 5sec..."); if (this.connectedToInternet) { console.log("error: " + err); // (currently fetch failed) new Notice("Connection lost :("); this.connectedToInternet = false; - this.writeToErrorLogFile(err); + await this.writeToErrorLogFile(err); } setTimeout(() => { this.checkingForConnectivity = true; this.checkForConnectivity(); }, 5000); } - this.writeToVerboseLogFile("LOG: Exited checkForConnectivity"); + await this.writeToVerboseLogFile("LOG: Exited checkForConnectivity"); }; - notifyError = () => { + notifyError = async () => { if (this.haltAllOperations) { return; } @@ -347,7 +351,7 @@ export default class driveSyncPlugin extends Plugin { this.pendingSync = true; new Notice("ERROR: Something went wrong! Sync might be paused!"); } - this.writeToVerboseLogFile("LOG: Error occured"); + await this.writeToVerboseLogFile("LOG: Error occured"); // check if the time between this error and last error was less than a minute: if (new Date().getTime() - this.lastErrorTime.getTime() < 60000) { this.totalErrorsWithinAMinute++; @@ -382,7 +386,7 @@ export default class driveSyncPlugin extends Plugin { return; } try { - this.writeToVerboseLogFile("LOG: Enerting cleanInstall"); + await this.writeToVerboseLogFile("LOG: Enerting cleanInstall"); new Notice("Creating vault in Google Drive..."); var res = await uploadFolder( this.settings.accessToken, @@ -413,17 +417,17 @@ export default class driveSyncPlugin extends Plugin { new Notice("Please reload the plug-in.", 5000); } catch (err) { new Notice("ERROR: Unable to initialize Vault in Google Drive"); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); } - this.writeToVerboseLogFile("LOG: Exited cleanInstall"); + await this.writeToVerboseLogFile("LOG: Exited cleanInstall"); }; refreshAll = async () => { if (this.haltAllOperations) { return; } - this.writeToVerboseLogFile("LOG: Entering refreshAll"); + await this.writeToVerboseLogFile("LOG: Entering refreshAll"); try { if (!this.connectedToInternet) { console.log("ERROR: Connectivity lost, not refreshing..."); @@ -443,7 +447,7 @@ export default class driveSyncPlugin extends Plugin { } else { this.alreadyRefreshing = true; } - this.refreshFilesListInDriveAndStoreInSettings(); + await this.refreshFilesListInDriveAndStoreInSettings(); /* refresh both the files list */ this.cloudFiles = []; this.localFiles = []; @@ -462,7 +466,9 @@ export default class driveSyncPlugin extends Plugin { !this.deletingList.includes(file) // is not currently being deleted ); - this.writeToVerboseLogFile("LOG: Deleting files"); + await this.writeToVerboseLogFile( + "LOG: Deleting files in refreshAll" + ); /* delete tracked but not-in-drive-anymore files */ this.app.vault.getFiles().map(async (file) => { if ( @@ -483,7 +489,9 @@ export default class driveSyncPlugin extends Plugin { } }); - this.writeToVerboseLogFile("LOG: Downloading missing files"); + await this.writeToVerboseLogFile( + "LOG: Downloading missing files in refreshAll" + ); /* download new files or files that were renamed */ if (toDownload.length) { new Notice("Downloading missing files", 2500); @@ -533,17 +541,19 @@ export default class driveSyncPlugin extends Plugin { } catch (err) { this.notifyError(); this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.writeToErrorLogFile(err); this.alreadyRefreshing = false; } - this.writeToVerboseLogFile("LOG: Exited refreshAll"); + await this.writeToVerboseLogFile("LOG: Exited refreshAll"); }; uploadNewNotesFile = async (newFile: TFile) => { if (this.haltAllOperations) { return; } try { - this.writeToVerboseLogFile("LOG: Entering uploadNewNotesFile"); + await this.writeToVerboseLogFile( + "LOG: Entering uploadNewNotesFile" + ); if (!this.connectedToInternet) { console.log("ERROR: Connectivity lost, not uploading..."); return; @@ -587,19 +597,19 @@ export default class driveSyncPlugin extends Plugin { this.writingFile = false; this.cloudFiles.push(newFile.path); - this.refreshFilesListInDriveAndStoreInSettings(); + await this.refreshFilesListInDriveAndStoreInSettings(); this.currentlyUploading = null; new Notice("Uploaded!"); - this.writeToVerboseLogFile("LOG: Exited uploadNewNotesFile"); + await this.writeToVerboseLogFile("LOG: Exited uploadNewNotesFile"); return id; } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); this.writingFile = false; this.currentlyUploading = null; - this.writeToVerboseLogFile("LOG: Exited uploadNewNotesFile"); + await this.writeToVerboseLogFile("LOG: Exited uploadNewNotesFile"); } }; @@ -611,7 +621,7 @@ export default class driveSyncPlugin extends Plugin { if (this.haltAllOperations) { return; } - this.writeToVerboseLogFile("LOG: Entering getLatestContent"); + await this.writeToVerboseLogFile("LOG: Entering getLatestContent"); if (!this.connectedToInternet) { console.log( "ERROR: Connectivity lost, not fetching latest content..." @@ -670,11 +680,11 @@ export default class driveSyncPlugin extends Plugin { } } } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); } - this.writeToVerboseLogFile("LOG: Exited getLatestContent"); + await this.writeToVerboseLogFile("LOG: Exited getLatestContent"); }; uploadNewAttachment = async (e: TFile) => { @@ -682,7 +692,9 @@ export default class driveSyncPlugin extends Plugin { return; } try { - this.writeToVerboseLogFile("LOG: Entering uploadNewAttachment"); + await this.writeToVerboseLogFile( + "LOG: Entering uploadNewAttachment" + ); new Notice("Uploading new attachment!"); var buffer: any = await this.app.vault.readBinary(e); const fileExtensionPattern = /\..*/; @@ -713,15 +725,15 @@ export default class driveSyncPlugin extends Plugin { ); return id; } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); } - this.writeToVerboseLogFile("LOG: Exited uploadNewAttachment"); + await this.writeToVerboseLogFile("LOG: Exited uploadNewAttachment"); }; updateLastSyncMetaTag = async (e: TFile) => { - this.writeToVerboseLogFile("LOG: Entering updateLastSyncMetaTag"); + await this.writeToVerboseLogFile("LOG: Entering updateLastSyncMetaTag"); var content = await this.app.vault.read(e); var metaExists = metaPattern.test(content); @@ -751,11 +763,13 @@ export default class driveSyncPlugin extends Plugin { `---\nlastSync: ${new Date().toString()}\n---\n` + content ); } - this.writeToVerboseLogFile("LOG: Exited updateLastSyncMetaTag"); + await this.writeToVerboseLogFile("LOG: Exited updateLastSyncMetaTag"); }; writeToPendingSyncFile = async () => { - this.writeToVerboseLogFile("LOG: Entering writeToPendingSyncFile"); + await this.writeToVerboseLogFile( + "LOG: Entering writeToPendingSyncFile" + ); let pendingSyncFile = this.app.vault.getAbstractFileByPath( PENDING_SYNC_FILE_NAME ); @@ -785,7 +799,7 @@ export default class driveSyncPlugin extends Plugin { }) ); } - this.writeToVerboseLogFile("LOG: Exited writeToPendingSyncFile"); + await this.writeToVerboseLogFile("LOG: Exited writeToPendingSyncFile"); }; refreshFilesListInDriveAndStoreInSettings = async () => { if (this.haltAllOperations) { @@ -798,7 +812,7 @@ export default class driveSyncPlugin extends Plugin { in case of offline operations when even the initial fetch request for retreiving the files list also fails */ - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: Entering refreshFilesListInDriveAndStoreInSettings" ); try { @@ -809,16 +823,16 @@ export default class driveSyncPlugin extends Plugin { } catch (err) { this.notifyError(); this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.writeToErrorLogFile(err); } this.saveSettings(); - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: Exiting refreshFilesListInDriveAndStoreInSettings" ); }; writeToErrorLogFile = async (log: Error) => { - this.writeToVerboseLogFile("LOG: Entering writeToErrorLogFile"); + await this.writeToVerboseLogFile("LOG: Entering writeToErrorLogFile"); if (!this.settings.errorLoggingToFile) { return; } @@ -847,49 +861,59 @@ export default class driveSyncPlugin extends Plugin { }` ); } - this.writeToVerboseLogFile("LOG: Exited writeToErrorLogFile"); + await this.writeToVerboseLogFile("LOG: Exited writeToErrorLogFile"); }; writeToVerboseLogFile = async (log: string) => { if (!this.settings.verboseLoggingToFile) { return; } - let errorLogFile = this.app.vault.getAbstractFileByPath( + let verboseLogFile = this.app.vault.getAbstractFileByPath( VERBOSE_LOG_FILE_NAME ); console.log(log); let content: string; - if (errorLogFile instanceof TFile) { - content = !this.verboseLoggingForTheFirstTimeInThisSession - ? await this.app.vault.read(errorLogFile) - : ""; - await this.app.vault.modify(errorLogFile, `${content}\n\n${log}`); - this.verboseLoggingForTheFirstTimeInThisSession = false; - } else { - await this.app.vault.create(VERBOSE_LOG_FILE_NAME, `${log}`); + try { + if (verboseLogFile instanceof TFile) { + content = !this.verboseLoggingForTheFirstTimeInThisSession + ? await this.app.vault.read(verboseLogFile) + : ""; + await this.app.vault.modify( + verboseLogFile, + `${content}\n\n${log}` + ); + console.log("modified", log, `${content}\n\n${log}`); + this.verboseLoggingForTheFirstTimeInThisSession = false; + } else { + await this.app.vault.create(VERBOSE_LOG_FILE_NAME, `${log}`); + } + } catch (err) { + console.log(err); } }; async onload() { await this.loadSettings(); - this.writeToVerboseLogFile("LOG: getAccessToken"); + await this.writeToVerboseLogFile("LOG: getAccessToken"); var res: any = await getAccessToken(this.settings.refreshToken, true); // get accessToken var count = 0; while (res == "error") { new Notice( "ERROR: Couldn't fetch accessToken. Trying again in 5 secs, please wait..." ); - this.writeToErrorLogFile( + await this.writeToErrorLogFile( new Error( "ERROR: Couldn't fetch accessToken. Trying again in 5 secs." ) ); - this.writeToVerboseLogFile("LOG: failed to fetch accessToken"); + await this.writeToVerboseLogFile( + "LOG: failed to fetch accessToken" + ); if (!this.settings.refreshToken) { - this.writeToVerboseLogFile("LOG: no refreshToken"); + await this.writeToVerboseLogFile("LOG: no refreshToken"); break; } console.log("Trying to get accessToken again after 5secs..."); @@ -901,7 +925,7 @@ export default class driveSyncPlugin extends Plugin { resolvePromise(); }, 5000); await promise; - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: trying to fetch accessToken again" ); res = await getAccessToken(this.settings.refreshToken); @@ -951,7 +975,7 @@ export default class driveSyncPlugin extends Plugin { try { if (res != "error") { - this.writeToVerboseLogFile("LOG: received accessToken"); + await this.writeToVerboseLogFile("LOG: received accessToken"); // if accessToken is available this.settings.accessToken = res.access_token; this.settings.validToken = true; @@ -960,10 +984,12 @@ export default class driveSyncPlugin extends Plugin { (folder: any) => folder.name == "obsidian" ); if (reqFolder.length) { - this.writeToVerboseLogFile("LOG: rootFolder available"); + await this.writeToVerboseLogFile( + "LOG: rootFolder available" + ); this.settings.rootFolderId = reqFolder[0].id; // set the rootFolder or obsidian folder id } else { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: rootFolder unavailable, uploading" ); new Notice("Initializing required files"); // else create the folder @@ -975,8 +1001,8 @@ export default class driveSyncPlugin extends Plugin { this.saveSettings(); } } catch (err) { - this.notifyError(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.writeToErrorLogFile(err); new Notice("FATAL ERROR: Could not upload rootFile"); } // else { @@ -986,7 +1012,7 @@ export default class driveSyncPlugin extends Plugin { // } if (this.settings.validToken) { try { - this.writeToVerboseLogFile("LOG: getting vault id"); + await this.writeToVerboseLogFile("LOG: getting vault id"); this.settings.vaultId = await getVaultId( // get vaultId for the current fold this.settings.accessToken, @@ -994,7 +1020,7 @@ export default class driveSyncPlugin extends Plugin { this.settings.rootFolderId ); } catch (err) { - this.writeToErrorLogFile(err); + await this.writeToErrorLogFile(err); new Notice( "FATAL ERROR: Couldn't get VaultID from Google Drive :(" ); @@ -1002,7 +1028,7 @@ export default class driveSyncPlugin extends Plugin { return; } if (this.settings.vaultId == "NOT FOUND") { - this.writeToVerboseLogFile("LOG: vault not found"); + await this.writeToVerboseLogFile("LOG: vault not found"); // if vault doesn't exist this.settings.vaultInit = false; new Notice( @@ -1016,7 +1042,7 @@ export default class driveSyncPlugin extends Plugin { // if vault exists this.settings.vaultInit = true; await this.completeAllPendingSyncs(); - this.refreshAll(); + await this.refreshAll(); this.registerInterval( window.setInterval(async () => { this.refreshAll(); @@ -1026,7 +1052,7 @@ export default class driveSyncPlugin extends Plugin { } // This adds a settings tab so the user can configure various aspects of the plugin - this.writeToVerboseLogFile("LOG: adding settings UI"); + await this.writeToVerboseLogFile("LOG: adding settings UI"); this.addSettingTab(new syncSettings(this.app, this)); if (!this.settings.vaultInit) return; @@ -1044,14 +1070,14 @@ export default class driveSyncPlugin extends Plugin { return; } if (this.completingPendingSync) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: not renaming as pending sync is ongoing" ); return; } try { if (!this.connectedToInternet) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: Connectivity lost, not renaming files to Google Drive" ); console.log( @@ -1067,7 +1093,7 @@ export default class driveSyncPlugin extends Plugin { !this.cloudFiles.includes(oldpath) && !this.renamedWhileOffline.get(oldpath) ) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: new file created while offline" ); if (newFile instanceof TFile) { @@ -1082,7 +1108,7 @@ export default class driveSyncPlugin extends Plugin { this.finalNamesForFileID.set(id, newFile.path); } } else { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: renamed while offline" ); let idIfWasAlreadyRenamedOffline = @@ -1122,7 +1148,9 @@ export default class driveSyncPlugin extends Plugin { return; } - this.writeToVerboseLogFile("LOG: renaming while online"); + await this.writeToVerboseLogFile( + "LOG: renaming while online" + ); /* actual renaming of file */ var id; var reqFile = ""; // required for changing the name of the file in the cloudsFile list @@ -1147,13 +1175,15 @@ export default class driveSyncPlugin extends Plugin { this.renamingList.indexOf(oldpath), 1 ); - this.writeToVerboseLogFile("LOG: renamed while online"); + await this.writeToVerboseLogFile( + "LOG: renamed while online" + ); - this.refreshFilesListInDriveAndStoreInSettings(); + await this.refreshFilesListInDriveAndStoreInSettings(); } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); this.renamingList = []; } }) @@ -1164,7 +1194,7 @@ export default class driveSyncPlugin extends Plugin { return; } if (this.completingPendingSync) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: not uploading as pending sync is ongoing" ); return; @@ -1174,12 +1204,12 @@ export default class driveSyncPlugin extends Plugin { console.log( "ERROR: Connectivity lost, not uploading files to Google Drive..." ); - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: Connectivity lost, not uploading files to Google Drive" ); if (e instanceof TFile && !/-synced\.*/.test(e.path)) { if (e.extension != "md") { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: created attachment while offline" ); let id = randomUUID(); @@ -1200,16 +1230,16 @@ export default class driveSyncPlugin extends Plugin { if (e instanceof TFile && !/-synced\.*/.test(e.path)) { if (e.extension != "md") { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: created attachment while online" ); await this.uploadNewAttachment(e); } } } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); this.currentlyUploading = null; } }) @@ -1220,7 +1250,7 @@ export default class driveSyncPlugin extends Plugin { return; } if (this.completingPendingSync) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: not deleting as pending sync is ongoing" ); return; @@ -1231,7 +1261,7 @@ export default class driveSyncPlugin extends Plugin { console.log( "ERROR: Connectivity lost, not deleting files from Google Drive..." ); - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: Connectivity lost, not deleting files from Google Drive" ); let id; @@ -1240,7 +1270,7 @@ export default class driveSyncPlugin extends Plugin { id = file.id; } }); - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: deleting while offline" ); this.pendingSyncItems.push({ @@ -1262,7 +1292,9 @@ export default class driveSyncPlugin extends Plugin { }); this.deletingList.push(e.path); - this.writeToVerboseLogFile("LOG: deleting while online"); + await this.writeToVerboseLogFile( + "LOG: deleting while online" + ); var successful = await deleteFile( this.settings.accessToken, id @@ -1274,11 +1306,11 @@ export default class driveSyncPlugin extends Plugin { 1 ); - this.refreshFilesListInDriveAndStoreInSettings(); + await this.refreshFilesListInDriveAndStoreInSettings(); } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); this.deletingList = []; } }) @@ -1289,7 +1321,7 @@ export default class driveSyncPlugin extends Plugin { return; } if (this.completingPendingSync) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: not modifying because pending sync" ); return; @@ -1299,7 +1331,7 @@ export default class driveSyncPlugin extends Plugin { console.log( "ERROR: Connectivity lost, not modifying files on Google Drive..." ); - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: Connectivity lost, not modifying files on Google Drive" ); if (!this.cloudFiles.length) { @@ -1313,7 +1345,7 @@ export default class driveSyncPlugin extends Plugin { !this.renamedWhileOffline.get(e.path) ) { if (e instanceof TFile) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: created file while offline" ); let id = randomUUID(); @@ -1347,7 +1379,7 @@ export default class driveSyncPlugin extends Plugin { ) { this.pendingSyncItems.pop(); } - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: modifying file while offline" ); this.pendingSyncItems.push({ @@ -1361,7 +1393,7 @@ export default class driveSyncPlugin extends Plugin { } if (!this.cloudFiles.includes(e.path)) { if (e instanceof TFile) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: created file while online" ); this.uploadNewNotesFile(e); @@ -1400,7 +1432,7 @@ export default class driveSyncPlugin extends Plugin { }); var buffer = await this.app.vault.readBinary(e); while (this.syncQueue) { - this.writeToVerboseLogFile( + await this.writeToVerboseLogFile( "LOG: modifying file while online" ); var res = await modifyFile( @@ -1421,9 +1453,9 @@ export default class driveSyncPlugin extends Plugin { setIcon(this.statusBarItem, "checkmark"); }, 2250); } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); this.syncQueue = false; this.writingFile = false; this.timer = null; @@ -1478,9 +1510,9 @@ export default class driveSyncPlugin extends Plugin { ); new Notice("Uploaded!"); } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); } } ); @@ -1551,9 +1583,9 @@ export default class driveSyncPlugin extends Plugin { ); new Notice("Uploaded!"); } catch (err) { - this.notifyError(); - this.checkForConnectivity(); - this.writeToErrorLogFile(err); + await this.notifyError(); + await this.checkForConnectivity(); + await this.writeToErrorLogFile(err); } }, }); diff --git a/package.json b/package.json index 49c23c5..eb63eca 100644 --- a/package.json +++ b/package.json @@ -24,5 +24,6 @@ "dependencies": { "axios": "^1.1.3", "short-unique-id": "^5.0.3" - } + }, + "packageManager": "pnpm@8.15.5+sha1.a58c038faac410c947dbdb93eb30994037d0fce2" }