@@ -650,8 +650,6 @@ async function runWatchProtocol(
650650}
651651
652652async function watchProtocolCycle ( config , entriesPath , sandbox , cycle ) {
653- const oldFiles = config . previous_entries || [ ]
654-
655653 // Re-parse the config file to get the latest list of data files to copy
656654 const newFiles = await fs . promises . readFile ( entriesPath ) . then ( JSON . parse )
657655
@@ -660,21 +658,26 @@ async function watchProtocolCycle(config, entriesPath, sandbox, cycle) {
660658 cycle . sources . hasOwnProperty ( `${ JS_BINARY__WORKSPACE } /${ f } ` )
661659 )
662660
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+ }
666671
667- // Sync changed files
672+ await Promise . all ( [
673+ deleteFiles ( toDelete , [ ] , sandbox ) ,
668674 syncFiles (
669675 filesToSync ,
670676 sandbox ,
671677 config . grant_sandbox_write_permissions ,
672678 cycleSyncRecurse . bind ( null , cycle )
673679 ) ,
674680 ] )
675-
676- // The latest state of copied data files
677- config . previous_entries = newFiles
678681}
679682
680683async function cycleSyncRecurse ( cycle , file , isDirectory , sandbox , writePerm ) {
0 commit comments