From d8564add7a8b3ef252ae48c55e03a0834d767add Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 25 May 2016 17:02:02 +0200 Subject: [PATCH] Be a little more defensive when retaining/releasing recovery files --- src/main-process/file-recovery-service.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main-process/file-recovery-service.js b/src/main-process/file-recovery-service.js index 0dc12ef06..d17d15c8b 100644 --- a/src/main-process/file-recovery-service.js +++ b/src/main-process/file-recovery-service.js @@ -24,7 +24,12 @@ export default class FileRecoveryService { ) this.recoveryFilesByFilePath.set(path, recoveryFile) } - recoveryFile.retain() + + try { + recoveryFile.retain() + } catch (err) { + console.log(`Couldn't retain ${recoveryFile.recoveryPath}. Code: ${err.code}. Message: ${err.message}`) + } if (!this.observedWindows.has(window)) { this.observedWindows.add(window) @@ -39,7 +44,11 @@ export default class FileRecoveryService { didSavePath (window, path) { const recoveryFile = this.recoveryFilesByFilePath.get(path) if (recoveryFile != null) { - recoveryFile.release() + try { + recoveryFile.release() + } catch (err) { + console.log(`Couldn't release ${recoveryFile.recoveryPath}. Code: ${err.code}. Message: ${err.message}`) + } if (recoveryFile.isReleased()) this.recoveryFilesByFilePath.delete(path) this.recoveryFilesByWindow.get(window).delete(recoveryFile) }