@@ -394,29 +394,25 @@ export class SynchronizeService {
394394 // 脚本存在但是文件不存在,则读取.meta.json内容判断是否需要删除脚本
395395 if ( ! file . script ) {
396396 result . push (
397- new Promise ( ( resolve ) => {
398- const handler = async ( ) => {
399- // 读取meta文件
400- const meta = await fs . open ( file . meta ! ) ;
401- const metaJson = ( await meta . read ( "string" ) ) as string ;
402- const metaObj = JSON . parse ( metaJson ) as SyncMeta ;
403- if ( metaObj . isDeleted ) {
404- if ( script ) {
405- this . script . deleteScript ( script . uuid ) ;
406- InfoNotification (
407- i18n . t ( "notification.script_sync_delete" ) ,
408- i18n . t ( "notification.script_sync_delete_desc" , { scriptName : i18nName ( script ) } )
409- ) ;
410- }
411- scriptMap . delete ( uuid ) ;
412- } else {
413- // 否则认为是一个无效的.meta文件,进行删除
414- await fs . delete ( file . meta ! . path ) ;
397+ ( async ( ) => {
398+ // 读取meta文件
399+ const meta = await fs . open ( file . meta ! ) ;
400+ const metaJson = ( await meta . read ( "string" ) ) as string ;
401+ const metaObj = JSON . parse ( metaJson ) as SyncMeta ;
402+ if ( metaObj . isDeleted ) {
403+ if ( script ) {
404+ this . script . deleteScript ( script . uuid ) ;
405+ InfoNotification (
406+ i18n . t ( "notification.script_sync_delete" ) ,
407+ i18n . t ( "notification.script_sync_delete_desc" , { scriptName : i18nName ( script ) } )
408+ ) ;
415409 }
416- resolve ( ) ;
417- } ;
418- handler ( ) ;
419- } )
410+ scriptMap . delete ( uuid ) ;
411+ } else {
412+ // 否则认为是一个无效的.meta文件,进行删除
413+ await fs . delete ( file . meta ! . name ) ;
414+ }
415+ } ) ( )
420416 ) ;
421417 return ;
422418 }
@@ -503,9 +499,10 @@ export class SynchronizeService {
503499 // 保存脚本猫同步状态
504500 const syncFile = await fs . create ( "scriptcat-sync.json" ) ;
505501 await syncFile . write ( JSON . stringify ( scriptcatSync , null , 2 ) ) ;
506- this . logger . info ( "sync scriptcat sync file success" ) ;
502+ this . logger . info ( "sync scriptcat- sync.json file success" ) ;
507503 }
508504 // 重新获取文件列表,保存文件摘要
505+ this . logger . info ( "update file digest" ) ;
509506 await this . updateFileDigest ( fs ) ;
510507 this . logger . info ( "sync complete" ) ;
511508 return ;
0 commit comments