mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2026-06-18 12:50:44 -04:00
fix bug
Former-commit-id: 2fbb67d39db7aba0f55de5790bbb01dce3285e19
This commit is contained in:
@@ -166,24 +166,44 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
.ipcRenderer.sendSync("storage-location", "ping");
|
||||
let sourcePath = path.join(storageLocation, "config", "readerConfig.json");
|
||||
let readerConfig: any;
|
||||
try {
|
||||
readerConfig = JSON.parse(
|
||||
fs.readFileSync(sourcePath, { encoding: "utf8", flag: "r" })
|
||||
);
|
||||
} catch (error) {
|
||||
BackupUtil.backup(
|
||||
this.props.books,
|
||||
this.props.notes,
|
||||
this.props.bookmarks,
|
||||
() => {
|
||||
this.props.handleMessage("Sync Successfully");
|
||||
this.props.handleMessageBox(true);
|
||||
},
|
||||
5,
|
||||
() => {}
|
||||
);
|
||||
return;
|
||||
}
|
||||
fs.readFile(sourcePath, "utf8", (err, data) => {
|
||||
if (err) {
|
||||
BackupUtil.backup(
|
||||
this.props.books,
|
||||
this.props.notes,
|
||||
this.props.bookmarks,
|
||||
() => {
|
||||
this.props.handleMessage("Sync Successfully");
|
||||
this.props.handleMessageBox(true);
|
||||
},
|
||||
5,
|
||||
() => {}
|
||||
);
|
||||
return;
|
||||
}
|
||||
const readerConfig = JSON.parse(data);
|
||||
if (
|
||||
readerConfig &&
|
||||
localStorage.getItem("lastSyncTime") &&
|
||||
parseInt(readerConfig.lastSyncTime) >
|
||||
parseInt(localStorage.getItem("lastSyncTime")!)
|
||||
) {
|
||||
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,
|
||||
() => {}
|
||||
);
|
||||
}
|
||||
});
|
||||
//如果同步文件夹的记录较新,就从同步文件夹同步数据到Koodo
|
||||
|
||||
if (
|
||||
|
||||
@@ -45,24 +45,33 @@ export const moveData = (
|
||||
);
|
||||
var zip = new AdmZip(path.join(dirPath, file.name));
|
||||
zip.extractAllTo(/*target path*/ dataPath, /*overwrite*/ true);
|
||||
try {
|
||||
const fs = window.require("fs-extra");
|
||||
|
||||
fs.remove(path.join(dirPath, file.name), async (err) => {
|
||||
if (err) console.log(err);
|
||||
if (driveIndex === 4) {
|
||||
let deleteBooks = books.map((item) => {
|
||||
return localforage.removeItem(item.key);
|
||||
});
|
||||
await Promise.all(deleteBooks);
|
||||
}
|
||||
if (driveIndex === 5) {
|
||||
handleFinish();
|
||||
}
|
||||
if (driveIndex === 4) {
|
||||
let deleteBooks = books.map((item) => {
|
||||
return localforage.removeItem(item.key);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e, "移动失败");
|
||||
await Promise.all(deleteBooks);
|
||||
}
|
||||
if (driveIndex === 5) {
|
||||
handleFinish();
|
||||
}
|
||||
// try {
|
||||
// const fs = window.require("fs-extra");
|
||||
|
||||
// fs.remove(path.join(dirPath, file.name), async (err) => {
|
||||
// if (err) console.log(err);
|
||||
// if (driveIndex === 4) {
|
||||
// let deleteBooks = books.map((item) => {
|
||||
// return localforage.removeItem(item.key);
|
||||
// });
|
||||
// await Promise.all(deleteBooks);
|
||||
// }
|
||||
// if (driveIndex === 5) {
|
||||
// handleFinish();
|
||||
// }
|
||||
// });
|
||||
// } catch (e) {
|
||||
// console.error(e, "移动失败");
|
||||
// }
|
||||
};
|
||||
};
|
||||
class SyncUtil {
|
||||
|
||||
Reference in New Issue
Block a user