From cd7a77d190be5811bc5ed513032af0dd0e8c8120 Mon Sep 17 00:00:00 2001 From: troyeguo <13820674+troyeguo@users.noreply.github.com> Date: Sun, 11 Apr 2021 14:28:39 +0800 Subject: [PATCH] fix bug Former-commit-id: c683b18c102388b880ace99f792d1d2f6d2fc595 --- src/containers/header/component.tsx | 40 +++++++++++++++++++---------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/containers/header/component.tsx b/src/containers/header/component.tsx index 442d8b4a..b22c2a57 100644 --- a/src/containers/header/component.tsx +++ b/src/containers/header/component.tsx @@ -115,19 +115,33 @@ class Header extends React.Component { .require("electron") .ipcRenderer.sendSync("storage-location", "ping"); let sourcePath = path.join(storageLocation, "config", "readerConfig.json"); - const readerConfig = JSON.parse( - fs.readFileSync(sourcePath, { encoding: "utf8", flag: "r" }) - ); - //如果同步文件夹的记录较新,就从同步文件夹同步数据到Koodo - if ( - localStorage.getItem("lastSyncTime") && - parseInt(readerConfig.lastSyncTime) > - parseInt(localStorage.getItem("lastSyncTime")!) - ) { - console.log(1); - this.syncFromLocation(); - } else { - //否则就把Koodo中数据同步到同步文件夹 + try { + const readerConfig = JSON.parse( + fs.readFileSync(sourcePath, { encoding: "utf8", flag: "r" }) + ); + //如果同步文件夹的记录较新,就从同步文件夹同步数据到Koodo + if ( + localStorage.getItem("lastSyncTime") && + parseInt(readerConfig.lastSyncTime) > + parseInt(localStorage.getItem("lastSyncTime")!) + ) { + console.log(1); + this.syncFromLocation(); + } else { + //否则就把Koodo中数据同步到同步文件夹 + BackupUtil.backup( + this.props.books, + this.props.notes, + this.props.bookmarks, + () => { + this.props.handleMessage("Sync Successfully"); + this.props.handleMessageBox(true); + }, + 5, + () => {} + ); + } + } catch (error) { BackupUtil.backup( this.props.books, this.props.notes,