Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Use native retries for directory deletes
Hakan Shehu1d9df2fa5c36
diff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.tsindex 54dad1a8..07d7a804 100644--- a/apps/desktop/forge.config.ts+++ b/apps/desktop/forge.config.ts@@ -150,7 +150,12 @@ const config: ForgeConfig = {const destNodeModules = './node_modules';// First clear the node_modules directory- await fs.rm(destNodeModules, { recursive: true, force: true });+ await fs.rm(destNodeModules, {+ recursive: true,+ force: true,+ maxRetries: 3,+ retryDelay: 1000,+ });// Ensure the destination directory existsawait fs.mkdir(destNodeModules, { recursive: true });@@ -163,7 +168,16 @@ const config: ForgeConfig = {},postPackage: async () => {// Remove the node_modules directory- await fs.rm('./node_modules', { recursive: true, force: true });+ try {+ await fs.rm('./node_modules', {+ recursive: true,+ force: true,+ maxRetries: 3,+ retryDelay: 1000,+ });+ } catch (error) {+ console.error(error);+ }},packageAfterPrune: async (_, buildPath) => {// Remove empty node_modules folders that are left behinddiff --git a/apps/desktop/src/main/services/accounts/account-service.ts b/apps/desktop/src/main/services/accounts/account-service.tsindex 3b8279a9..470d5da3 100644--- a/apps/desktop/src/main/services/accounts/account-service.ts+++ b/apps/desktop/src/main/services/accounts/account-service.ts@@ -158,7 +158,12 @@ export class AccountService {const accountPath = getAccountDirectoryPath(this.account.id);if (fs.existsSync(accountPath)) {- fs.rmSync(accountPath, { recursive: true, force: true });+ fs.rmSync(accountPath, {+ recursive: true,+ force: true,+ maxRetries: 3,+ retryDelay: 1000,+ });}eventBus.publish({diff --git a/apps/desktop/src/main/services/workspaces/workspace-service.ts b/apps/desktop/src/main/services/workspaces/workspace-service.tsindex 324c2f92..0735a968 100644--- a/apps/desktop/src/main/services/workspaces/workspace-service.ts+++ b/apps/desktop/src/main/services/workspaces/workspace-service.ts@@ -141,7 +141,12 @@ export class WorkspaceService {);if (fs.existsSync(workspacePath)) {- fs.rmSync(workspacePath, { recursive: true, force: true });+ fs.rmSync(workspacePath, {+ recursive: true,+ force: true,+ maxRetries: 3,+ retryDelay: 1000,+ });}await this.account.databasediff --git a/scripts/src/emojis/index.ts b/scripts/src/emojis/index.tsindex bfe5fb4b..1654d63e 100644--- a/scripts/src/emojis/index.ts+++ b/scripts/src/emojis/index.ts@@ -404,21 +404,12 @@ const generateEmojis = async () => {console.log(`Cleaning up...`);- for (let attempt = 1; attempt <= 3; attempt++) {- try {- fs.rmSync(WORK_DIR_PATH, { recursive: true, force: true });- break;- } catch (err) {- if (attempt === 3) {- console.error(- `Failed to remove ${WORK_DIR_PATH} after 3 attempts: ${err}`- );- } else {- console.log(`Retry ${attempt}/3 to remove working directory...`);- await sleep(1000);- }- }- }+ fs.rmSync(WORK_DIR_PATH, {+ recursive: true,+ force: true,+ maxRetries: 5,+ retryDelay: 1000,+ });console.log(`All done. The 'emojis.db' file now contains everything!`);};diff --git a/scripts/src/icons/index.ts b/scripts/src/icons/index.tsindex d7fc8e2f..3ceb0872 100644--- a/scripts/src/icons/index.ts+++ b/scripts/src/icons/index.ts@@ -382,21 +382,13 @@ const generateIcons = async () => {processIconsIntoDb(db);console.log('Cleaning up...');- for (let attempt = 1; attempt <= 3; attempt++) {- try {- fs.rmSync(WORK_DIR_PATH, { recursive: true, force: true });- break;- } catch (err) {- if (attempt === 3) {- console.error(- `Failed to remove ${WORK_DIR_PATH} after 3 attempts: ${err}`- );- } else {- console.log(`Retry ${attempt}/3 to remove working directory...`);- await sleep(1000);- }- }- }+ fs.rmSync(WORK_DIR_PATH, {+ recursive: true,+ force: true,+ maxRetries: 5,+ retryDelay: 1000,+ });+console.log("All done. The 'icons.db' file now contains everything!");};