@@ -162,6 +162,7 @@ func (fms *FileManagerService) ConfigApply(ctx context.Context,
162162 return model .Error , errors .New ("fileOverview is nil" )
163163 }
164164
165+ // check if any file in request is outside the allowed directories
165166 allowedErr := fms .checkAllowedDirectory (fileOverview .GetFiles ())
166167 if allowedErr != nil {
167168 return model .Error , allowedErr
@@ -355,18 +356,24 @@ func (fms *FileManagerService) DetermineFileActions(
355356 // if file is in manifestFiles but not in modified files, file has been deleted
356357 // copy contents, set file action
357358 for fileName , manifestFile := range filesMap {
358- _ , exists := modifiedFiles [fileName ]
359+ _ , existsOnDisk := modifiedFiles [fileName ]
359360
360361 if ! fms .agentConfig .IsDirectoryAllowed (fileName ) {
361362 return nil , fmt .Errorf ("error deleting file %s: file not in allowed directories" , fileName )
362363 }
363364
365+ // if file is unmanaged skip deletion
366+ if manifestFile .GetUnmanaged () {
367+ slog .DebugContext (ctx , "skipping unmanaged file" , "file_name" , fileName )
368+ continue
369+ }
370+
364371 if _ , err := os .Stat (fileName ); os .IsNotExist (err ) {
365372 slog .DebugContext (ctx , "File already deleted, skipping" , "file" , fileName )
366373 continue
367374 }
368375
369- if ! exists {
376+ if ! existsOnDisk {
370377 fileDiff [fileName ] = & model.FileCache {
371378 File : manifestFile ,
372379 Action : model .Delete ,
@@ -382,6 +389,7 @@ func (fms *FileManagerService) DetermineFileActions(
382389
383390 // if file is unmanaged, action is set to unchanged so file is skipped when performing actions
384391 if modifiedFile .File .GetUnmanaged () {
392+ slog .DebugContext (ctx , "skipping unmanaged file" , "file_name" , fileName )
385393 continue
386394 }
387395 // if file doesn't exist in the current files, file has been added
@@ -729,6 +737,7 @@ func (fms *FileManagerService) convertToManifestFile(file *mpi.File, referenced
729737 Size : file .GetFileMeta ().GetSize (),
730738 Hash : file .GetFileMeta ().GetHash (),
731739 Referenced : referenced ,
740+ Unmanaged : file .Unmanaged ,
732741 },
733742 }
734743}
@@ -750,6 +759,7 @@ func (fms *FileManagerService) convertToFile(manifestFile *model.ManifestFile) *
750759 Hash : manifestFile .ManifestFileMeta .Hash ,
751760 Size : manifestFile .ManifestFileMeta .Size ,
752761 },
762+ Unmanaged : manifestFile .ManifestFileMeta .Unmanaged ,
753763 }
754764}
755765
0 commit comments