@@ -650,8 +650,6 @@ async function runWatchProtocol(
650
650
}
651
651
652
652
async function watchProtocolCycle ( config , entriesPath , sandbox , cycle ) {
653
- const oldFiles = config . previous_entries || [ ]
654
-
655
653
// Re-parse the config file to get the latest list of data files to copy
656
654
const newFiles = await fs . promises . readFile ( entriesPath ) . then ( JSON . parse )
657
655
@@ -660,21 +658,26 @@ async function watchProtocolCycle(config, entriesPath, sandbox, cycle) {
660
658
cycle . sources . hasOwnProperty ( `${ JS_BINARY__WORKSPACE } /${ f } ` )
661
659
)
662
660
663
- await Promise . all ( [
664
- // Remove files that were previously synced but are no longer in the updated list of files to sync
665
- deleteFiles ( oldFiles , newFiles , sandbox ) ,
661
+ // The files marked for deletion in this cycle
662
+ const toDelete = [ ]
663
+ for ( const l in cycle . sources ) {
664
+ if ( cycle . sources [ l ] === null ) {
665
+ toDelete . push ( [
666
+ l . slice ( JS_BINARY__WORKSPACE . length + 1 ) ,
667
+ /*isDirectory=*/ false ,
668
+ ] )
669
+ }
670
+ }
666
671
667
- // Sync changed files
672
+ await Promise . all ( [
673
+ deleteFiles ( toDelete , [ ] , sandbox ) ,
668
674
syncFiles (
669
675
filesToSync ,
670
676
sandbox ,
671
677
config . grant_sandbox_write_permissions ,
672
678
cycleSyncRecurse . bind ( null , cycle )
673
679
) ,
674
680
] )
675
-
676
- // The latest state of copied data files
677
- config . previous_entries = newFiles
678
681
}
679
682
680
683
async function cycleSyncRecurse ( cycle , file , isDirectory , sandbox , writePerm ) {
0 commit comments