diff --git a/package.json b/package.json index 7d72e55be..aa3440e4e 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "keycode": "^2.2.0", "lodash-id": "^0.14.0", "lowdb": "^1.0.0", - "picgo": "^1.5.0-alpha.0", + "picgo": "^1.5.0-alpha.3", "qrcode.vue": "^1.7.0", "shell-path": "2.1.0", "uuidv4": "^6.2.11", diff --git a/src/main/apis/app/uploader/apis.ts b/src/main/apis/app/uploader/apis.ts index 8f93e5d7b..ad77e0398 100644 --- a/src/main/apis/app/uploader/apis.ts +++ b/src/main/apis/app/uploader/apis.ts @@ -41,7 +41,7 @@ export const uploadClipboardFiles = async (): Promise => { trayWindow?.webContents?.send('clipboardFiles', []) trayWindow?.webContents?.send('uploadFiles', img) if (windowManager.has(IWindowList.SETTING_WINDOW)) { - windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery') + windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery') } return handleUrlEncode(img[0].imgUrl as string) } else { @@ -81,7 +81,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW // trayWindow just be created in mac/windows, not in linux windowManager.get(IWindowList.TRAY_WINDOW)?.webContents?.send('uploadFiles', imgs) if (windowManager.has(IWindowList.SETTING_WINDOW)) { - windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery') + windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery') } return result } else { diff --git a/src/main/lifeCycle/errorHandler.ts b/src/main/lifeCycle/errorHandler.ts index 19d9b2daa..d19e2588b 100644 --- a/src/main/lifeCycle/errorHandler.ts +++ b/src/main/lifeCycle/errorHandler.ts @@ -9,14 +9,23 @@ const LOG_PATH = path.join(STORE_PATH, '/picgo.log') // since the error may occur in picgo-core // so we can't use the log from picgo export const loggerWriter = (error: Error) => { - let log = `${dayjs().format('YYYY-MM-DD HH:mm:ss')} [PicGo ERROR] startup error` - if (error?.stack) { - log += `\n------Error Stack Begin------\n${util.format(error.stack)}\n-------Error Stack End-------\n` - } else { - const msg = JSON.stringify(error) - log += `${msg}\n` + try { + const time = dayjs().format('YYYY-MM-DD HH:mm:ss') + let log = `${time} [PicGo ERROR] process error begin` + if (error?.stack) { + log += `\n------Error Stack Begin------\n${util.format(error.stack)}\n-------Error Stack End-------\n` + } else { + const msg = JSON.stringify(error) + log += `${msg}\n` + } + log += `${time} [PicGo ERROR] process error end` + if (!fse.existsSync(LOG_PATH)) { + fse.ensureFileSync(LOG_PATH) + } + fse.appendFileSync(LOG_PATH, log) + } catch (e) { + console.error(e) } - fse.appendFileSync(LOG_PATH, log) } const handleProcessError = (error: Error) => { diff --git a/src/main/migrate/index.ts b/src/main/migrate/index.ts index 25a41562e..e2e32042d 100644 --- a/src/main/migrate/index.ts +++ b/src/main/migrate/index.ts @@ -35,6 +35,11 @@ const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IS const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galleryDB: DBStore, picgo: PicGoCore) => { const originGallery: ImgInfo[] = configDB.get('uploaded') + // if hasMigrate, we don't need to migrate + const hasMigrate: boolean = configDB.get('__migrateUploaded') + if (hasMigrate) { + return + } const configPath = configDB.getConfigPath() const configBakPath = path.join(path.dirname(configPath), 'config.bak.json') // migrate gallery from config to gallery db @@ -44,7 +49,8 @@ const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galler } await galleryDB.insertMany(originGallery) picgo.saveConfig({ - uploaded: [] + uploaded: [], + __migrateUploaded: true }) } } diff --git a/src/main/server/routerManager.ts b/src/main/server/routerManager.ts index eb2bdab83..5d58922e6 100644 --- a/src/main/server/routerManager.ts +++ b/src/main/server/routerManager.ts @@ -24,6 +24,7 @@ router.post('/upload', async ({ // upload with clipboard logger.info('[PicGo Server] upload clipboard file') const res = await uploadClipboardFiles() + logger.info('[PicGo Server] upload result:', res) if (res) { handleResponse({ response, @@ -51,6 +52,7 @@ router.post('/upload', async ({ }) const win = windowManager.getAvailableWindow() const res = await uploadChoosedFiles(win.webContents, pathList) + logger.info('[PicGo Server] upload result', res.join(' ; ')) if (res.length) { handleResponse({ response, diff --git a/src/renderer/layouts/Main.vue b/src/renderer/layouts/Main.vue index 2cbdd81bb..73d4549c0 100644 --- a/src/renderer/layouts/Main.vue +++ b/src/renderer/layouts/Main.vue @@ -270,6 +270,11 @@ export default class extends Vue {