From 7cb1f445629b09a765c87901bda621a628e0605f Mon Sep 17 00:00:00 2001 From: leejinho Date: Thu, 13 Feb 2020 11:02:12 +0900 Subject: [PATCH] =?UTF-8?q?bugfix=20::=201.=20=ED=8C=8C=EC=9D=BC=EB=8B=A4?= =?UTF-8?q?=EC=9A=B4=EB=A1=9C=EB=93=9C=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95.=202.=20=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EC=97=B4=EA=B8=B0=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ucap-webmessenger-electron/src/index.ts | 45 +++++++++++++------ .../app/services/authentication.service.ts | 18 ++++---- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index 758ab763..b510b68f 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -538,12 +538,19 @@ ipcMain.on( const fileName: string = args[1]; const mimeType: string = args[2]; const customSavePath: string = args[3]; - let savePath: string = path.join( - !!appStorage.downloadPath - ? appStorage.downloadPath - : app.getPath('downloads'), - fileName - ); + + let basePath = app.getPath('downloads'); + if (!!appStorage.downloadPath) { + try { + fse.mkdirpSync(appStorage.downloadPath); + basePath = appStorage.downloadPath; + } catch (err) { + log.error(err); + basePath = app.getPath('downloads'); + } + } + let savePath: string = path.join(basePath, fileName); + if (!!customSavePath) { savePath = customSavePath; } else { @@ -554,12 +561,12 @@ ipcMain.on( if (!err) { event.returnValue = savePath; } else { - log.info('SaveFile err', err); + log.error('SaveFile err', err); event.returnValue = undefined; } }); } catch (error) { - log.info('SaveFile error', error); + log.error('SaveFile error', error); event.returnValue = undefined; } } @@ -572,15 +579,25 @@ ipcMain.on( let folderItem: string = args[0]; const make: boolean = args[1]; if (!folderItem) { - folderItem = app.getPath('downloads'); + let basePath = app.getPath('downloads'); + if (!!appStorage.downloadPath) { + try { + basePath = appStorage.downloadPath; + } catch (err) { + log.error(err); + basePath = app.getPath('downloads'); + } + } + + folderItem = basePath; + } else { + if (make) { + fse.mkdirpSync(folderItem); + } } let isSuccess = true; - if (make) { - fse.ensureDirSync(folderItem); - } - - if (isSuccess && fse.existsSync(folderItem)) { + if (fse.existsSync(folderItem)) { shell.openItem(folderItem); } else { isSuccess = false; diff --git a/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts b/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts index 3dc29175..ef5726ca 100644 --- a/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts @@ -23,6 +23,7 @@ import { environment } from '../../environments/environment'; import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type'; import { Settings } from '@ucap-webmessenger/ui-settings'; import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native'; +import { join } from 'path'; @Injectable({ providedIn: 'root' @@ -71,9 +72,10 @@ export class AppAuthenticationService { ...environment.productConfig.defaultSettings, chat: { ...environment.productConfig.defaultSettings.chat, - downloadPath: `${await this.nativeService.getPath( - 'documents' - )}/Messenger downloads` + downloadPath: join( + await this.nativeService.getPath('documents'), + 'MessengerDownloads' + ) } } }; @@ -119,11 +121,11 @@ export class AppAuthenticationService { appUserInfo = { ...appUserInfo, settings: { - ...appUserInfo.settings, - general: { - ...appUserInfo.settings.general, - autoLogin: false - } + ...appUserInfo.settings, + general: { + ...appUserInfo.settings.general, + autoLogin: false + } } };