@@ -354,7 +354,11 @@ app.whenReady().then(() => {
354
354
} ) ;
355
355
356
356
showLoading ( ) ;
357
- tmpDir ( 'thumbnail' ) ;
357
+ if ( is . dev ) {
358
+ tmpDir ( path . join ( process . cwd ( ) , 'thumbnail' ) ) ;
359
+ } else {
360
+ tmpDir ( path . join ( appDataPath , 'thumbnail' ) ) ;
361
+ }
358
362
createWindow ( ) ;
359
363
registerAppMenu ( ) ;
360
364
@@ -582,15 +586,26 @@ const getFolderSize = (folderPath: string): number => {
582
586
} ;
583
587
584
588
const tmpDir = async ( path : string ) => {
585
- const pathExists = await fs . pathExistsSync ( path ) ;
586
- if ( pathExists ) {
587
- await fs . removeSync ( path ) ; // 删除文件, 不存在不会报错
589
+ try {
590
+ const pathExists = await fs . pathExistsSync ( path ) ;
591
+ log . info ( `[ipcMain] tmpDir: ${ path } -exists-${ pathExists } ` ) ;
592
+ if ( pathExists ) {
593
+ await fs . removeSync ( path ) ; // 删除文件, 不存在不会报错
594
+ }
595
+ await fs . emptyDirSync ( path ) ; // 清空目录, 不存在自动创建
596
+ log . info ( `[ipcMain] tmpDir: ${ path } -created-sucess` ) ;
597
+ } catch ( err ) {
598
+ log . error ( err )
588
599
}
589
- await fs . emptyDirSync ( path ) ; // 清空目录, 不存在自动创建
590
600
} ;
591
601
592
602
ipcMain . on ( 'tmpdir-manage' , ( event , action , trails ) => {
593
- const formatPath = path . join ( appDataPath , trails ) ;
603
+ let formatPath ;
604
+ if ( is . dev ) {
605
+ formatPath = path . join ( process . cwd ( ) , trails ) ;
606
+ } else {
607
+ formatPath = path . join ( appDataPath , trails ) ;
608
+ }
594
609
if ( action === 'rmdir' || action === 'mkdir' || action === 'init' ) tmpDir ( formatPath ) ;
595
610
if ( action === 'size' ) event . reply ( "tmpdir-manage-size" , getFolderSize ( formatPath ) ) ;
596
611
} ) ;
0 commit comments