@@ -195,7 +195,7 @@ func (fms *FileManagerService) UpdateOverview(
195195 delta := files .ConvertToMapOfFiles (response .GetOverview ().GetFiles ())
196196
197197 if len (delta ) != 0 {
198- return fms .updateFiles (ctx , delta , instanceID , iteration )
198+ return fms .updateFiles (ctx , delta , request . GetOverview (). GetFiles (), instanceID , iteration )
199199 }
200200
201201 return err
@@ -219,6 +219,7 @@ func (fms *FileManagerService) setupIdentifiers(ctx context.Context, iteration i
219219func (fms * FileManagerService ) updateFiles (
220220 ctx context.Context ,
221221 delta map [string ]* mpi.File ,
222+ fileOverview []* mpi.File ,
222223 instanceID string ,
223224 iteration int ,
224225) error {
@@ -234,7 +235,7 @@ func (fms *FileManagerService) updateFiles(
234235 iteration ++
235236 slog .Debug ("Updating file overview" , "attempt_number" , iteration )
236237
237- return fms .UpdateOverview (ctx , instanceID , diffFiles , iteration )
238+ return fms .UpdateOverview (ctx , instanceID , fileOverview , iteration )
238239}
239240
240241func (fms * FileManagerService ) UpdateFile (
@@ -728,7 +729,7 @@ func (fms *FileManagerService) DetermineFileActions(
728729 fileDiff := make (map [string ]* model.FileCache ) // Files that have changed, key is file name
729730 fileContents := make (map [string ][]byte ) // contents of the file, key is file name
730731
731- manifestFiles , filesMap , manifestFileErr := fms .manifestFile ()
732+ _ , filesMap , manifestFileErr := fms .manifestFile ()
732733
733734 if manifestFileErr != nil {
734735 if errors .Is (manifestFileErr , os .ErrNotExist ) {
@@ -769,14 +770,15 @@ func (fms *FileManagerService) DetermineFileActions(
769770 }
770771 // if file doesn't exist in the current files, file has been added
771772 // set file action
772- if ! ok {
773+ if _ , statErr := os .Stat (modifiedFile .File .GetFileMeta ().GetName ()); errors .Is (statErr , os .ErrNotExist ) {
774+ slog .Info ("File is not present on disk" , "file" , modifiedFile .File .GetFileMeta ().GetName ())
773775 modifiedFile .Action = model .Add
774776 fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
775777
776778 continue
777779 // if file currently exists and file hash is different, file has been updated
778780 // copy contents, set file action
779- } else if modifiedFile .File .GetFileMeta ().GetHash () != currentFile .GetFileMeta ().GetHash () {
781+ } else if ok && modifiedFile .File .GetFileMeta ().GetHash () != currentFile .GetFileMeta ().GetHash () {
780782 fileContent , readErr := os .ReadFile (fileName )
781783 if readErr != nil {
782784 return nil , nil , fmt .Errorf ("error reading file %s, error: %w" , fileName , readErr )
@@ -785,24 +787,6 @@ func (fms *FileManagerService) DetermineFileActions(
785787 fileContents [fileName ] = fileContent
786788 fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
787789 }
788-
789- // If the file is unreferenced we check if the file has been updated since the last time
790- // Also check if the unreferenced file still exists
791- if manifestFiles [modifiedFile .File .GetFileMeta ().GetName ()] != nil &&
792- ! manifestFiles [modifiedFile .File .GetFileMeta ().GetName ()].ManifestFileMeta .Referenced {
793- if fileStats , err := os .Stat (modifiedFile .File .GetFileMeta ().GetName ()); errors .Is (err , os .ErrNotExist ) {
794- modifiedFile .Action = model .Add
795- fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
796- } else if timestamppb .New (fileStats .ModTime ()) != modifiedFile .File .GetFileMeta ().GetModifiedTime () {
797- fileContent , readErr := os .ReadFile (fileName )
798- if readErr != nil {
799- return nil , nil , fmt .Errorf ("error reading file %s, error: %w" , fileName , readErr )
800- }
801- modifiedFile .Action = model .Update
802- fileContents [fileName ] = fileContent
803- fileDiff [modifiedFile .File .GetFileMeta ().GetName ()] = modifiedFile
804- }
805- }
806790 }
807791
808792 return fileDiff , fileContents , nil
0 commit comments