@@ -178,7 +178,7 @@ func (fms *FileManagerService) UpdateOverview(
178178 delta := files .ConvertToMapOfFiles (response .GetOverview ().GetFiles ())
179179
180180 if len (delta ) != 0 {
181- return fms .updateFiles (ctx , delta , instanceID , iteration )
181+ return fms .updateFiles (ctx , delta , request . GetOverview (). GetFiles (), instanceID , iteration )
182182 }
183183
184184 return err
@@ -202,6 +202,7 @@ func (fms *FileManagerService) setupIdentifiers(ctx context.Context, iteration i
202202func (fms * FileManagerService ) updateFiles (
203203 ctx context.Context ,
204204 delta map [string ]* mpi.File ,
205+ fileOverview []* mpi.File ,
205206 instanceID string ,
206207 iteration int ,
207208) error {
@@ -217,7 +218,7 @@ func (fms *FileManagerService) updateFiles(
217218 iteration ++
218219 slog .Debug ("Updating file overview" , "attempt_number" , iteration )
219220
220- return fms .UpdateOverview (ctx , instanceID , diffFiles , iteration )
221+ return fms .UpdateOverview (ctx , instanceID , fileOverview , iteration )
221222}
222223
223224func (fms * FileManagerService ) UpdateFile (
@@ -483,7 +484,7 @@ func (fms *FileManagerService) DetermineFileActions(
483484 fileDiff := make (map [string ]* model.FileCache ) // Files that have changed, key is file name
484485 fileContents := make (map [string ][]byte ) // contents of the file, key is file name
485486
486- manifestFiles , filesMap , manifestFileErr := fms .manifestFile ()
487+ _ , filesMap , manifestFileErr := fms .manifestFile ()
487488
488489 if manifestFileErr != nil {
489490 if errors .Is (manifestFileErr , os .ErrNotExist ) {
@@ -524,14 +525,15 @@ func (fms *FileManagerService) DetermineFileActions(
524525 }
525526 // if file doesn't exist in the current files, file has been added
526527 // set file action
527- if ! ok {
528+ if _ , statErr := os .Stat (modifiedFile .File .GetFileMeta ().GetName ()); errors .Is (statErr , os .ErrNotExist ) {
529+ slog .Info ("File is not present on disk" , "file" , modifiedFile .File .GetFileMeta ().GetName ())
528530 modifiedFile .Action = model .Add
529531 fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
530532
531533 continue
532534 // if file currently exists and file hash is different, file has been updated
533535 // copy contents, set file action
534- } else if modifiedFile .File .GetFileMeta ().GetHash () != currentFile .GetFileMeta ().GetHash () {
536+ } else if ok && modifiedFile .File .GetFileMeta ().GetHash () != currentFile .GetFileMeta ().GetHash () {
535537 fileContent , readErr := os .ReadFile (fileName )
536538 if readErr != nil {
537539 return nil , nil , fmt .Errorf ("error reading file %s, error: %w" , fileName , readErr )
@@ -540,24 +542,6 @@ func (fms *FileManagerService) DetermineFileActions(
540542 fileContents [fileName ] = fileContent
541543 fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
542544 }
543-
544- // If the file is unreferenced we check if the file has been updated since the last time
545- // Also check if the unreferenced file still exists
546- if manifestFiles [modifiedFile .File .GetFileMeta ().GetName ()] != nil &&
547- ! manifestFiles [modifiedFile .File .GetFileMeta ().GetName ()].ManifestFileMeta .Referenced {
548- if fileStats , err := os .Stat (modifiedFile .File .GetFileMeta ().GetName ()); errors .Is (err , os .ErrNotExist ) {
549- modifiedFile .Action = model .Add
550- fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
551- } else if timestamppb .New (fileStats .ModTime ()) != modifiedFile .File .GetFileMeta ().GetModifiedTime () {
552- fileContent , readErr := os .ReadFile (fileName )
553- if readErr != nil {
554- return nil , nil , fmt .Errorf ("error reading file %s, error: %w" , fileName , readErr )
555- }
556- modifiedFile .Action = model .Update
557- fileContents [fileName ] = fileContent
558- fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
559- }
560- }
561545 }
562546
563547 return fileDiff , fileContents , nil
0 commit comments