@@ -43,6 +43,7 @@ func (efo *ExternalFileOperator) DownloadExternalFile(ctx context.Context, fileA
4343) error {
4444 location := fileAction .File .GetExternalDataSource ().GetLocation ()
4545 permission := fileAction .File .GetFileMeta ().GetPermissions ()
46+ fileName := fileAction .File .GetFileMeta ().GetName ()
4647
4748 slog .InfoContext (ctx , "Downloading external file from" , "location" , location )
4849
@@ -54,29 +55,26 @@ func (efo *ExternalFileOperator) DownloadExternalFile(ctx context.Context, fileA
5455
5556 if downloadErr != nil {
5657 updateError = fmt .Errorf ("failed to download file %s from %s: %w" ,
57- fileAction . File . GetFileMeta (). GetName () , location , downloadErr )
58+ fileName , location , downloadErr )
5859
5960 return updateError
6061 }
6162
6263 if contentToWrite == nil {
6364 slog .DebugContext (ctx , "External file unchanged (304), skipping disk write." ,
64- "file" , fileAction . File . GetFileMeta (). GetName () )
65+ "file" , fileName )
6566
6667 // preserve previous behavior: mark as unchanged so later rename is skipped
6768 fileAction .Action = model .Unchanged
6869
6970 // persist headers if present
7071 if headers .ETag != "" || headers .LastModified != "" {
71- fileName := fileAction .File .GetFileMeta ().GetName ()
7272 efo .fileManagerService .externalFileHeaders [fileName ] = headers
7373 }
7474
7575 return nil
7676 }
7777
78- fileName := fileAction .File .GetFileMeta ().GetName ()
79-
8078 // Validate downloaded file type before writing to temp location.
8179 if err := efo .validateDownloadedFile (contentToWrite , fileName ); err != nil {
8280 return fmt .Errorf ("downloaded file validation failed for %s: %w" , fileName , err )
0 commit comments