@@ -327,8 +327,8 @@ func IsFileLocked(lockedInfo *flex.JobLockedInfo) bool {
327
327
return lockedInfo != nil && lockedInfo .ReadWriteLocked
328
328
}
329
329
330
- // FileExists returns whether the file exists.
331
- func FileExists (lockedInfo * flex.JobLockedInfo ) bool {
330
+ // FileExistedBeforeJob returns whether the file exists when the job was created .
331
+ func FileExistedBeforeJob (lockedInfo * flex.JobLockedInfo ) bool {
332
332
return lockedInfo .Exists
333
333
}
334
334
@@ -378,7 +378,7 @@ func BuildJobRequest(ctx context.Context, client Provider, mountPoint filesystem
378
378
}
379
379
380
380
lockedInfo := cfg .LockedInfo
381
- if ! IsFileLocked (lockedInfo ) && FileExists (lockedInfo ) {
381
+ if ! IsFileLocked (lockedInfo ) && FileExistedBeforeJob (lockedInfo ) {
382
382
return getRequestWithFailedPrecondition ("path lock has not been acquired" )
383
383
384
384
}
@@ -397,7 +397,7 @@ func BuildJobRequest(ctx context.Context, client Provider, mountPoint filesystem
397
397
}
398
398
399
399
if cfg .Download && cfg .RemotePath == "" {
400
- if ! FileExists (lockedInfo ) {
400
+ if ! FileExistedBeforeJob (lockedInfo ) {
401
401
return getRequestWithFailedPrecondition (fmt .Sprintf ("unable to determine remote path: %s" , fs .ErrNotExist .Error ()))
402
402
}
403
403
@@ -464,7 +464,7 @@ func PrepareFileStateForWorkRequests(ctx context.Context, client Provider, mount
464
464
465
465
alreadySynced := IsFileAlreadySynced (lockedInfo )
466
466
if cfg .StubLocal {
467
- if (cfg .Download && (cfg .Overwrite || ! FileExists (lockedInfo ))) || alreadySynced {
467
+ if (cfg .Download && (cfg .Overwrite || ! FileExistedBeforeJob (lockedInfo ))) || alreadySynced {
468
468
if mappings == nil {
469
469
mappings , err = util .GetMappings (ctx )
470
470
if err != nil && ! errors .Is (err , util .ErrMappingRSTs ) {
@@ -492,11 +492,11 @@ func PrepareFileStateForWorkRequests(ctx context.Context, client Provider, mount
492
492
return ErrJobAlreadyOffloaded
493
493
}
494
494
495
- if cfg .Download && ! cfg .Overwrite && FileExists (lockedInfo ) {
495
+ if cfg .Download && ! cfg .Overwrite && FileExistedBeforeJob (lockedInfo ) {
496
496
err = fmt .Errorf ("download would overwrite existing path but the overwrite flag was not set: %w" , fs .ErrExist )
497
497
return
498
498
}
499
- } else if FileExists (lockedInfo ) {
499
+ } else if FileExistedBeforeJob (lockedInfo ) {
500
500
if alreadySynced {
501
501
return GetErrJobAlreadyCompleteWithMtime (lockedInfo .Mtime .AsTime ())
502
502
}
@@ -552,8 +552,8 @@ func PrepareFileStateForWorkRequests(ctx context.Context, client Provider, mount
552
552
err = fmt .Errorf ("failed to collect information for new file: %w" , err )
553
553
return
554
554
}
555
+ lockedInfo .SetExists (false ) // Setting to false since the file did not previously exist.
555
556
lockedInfo .SetReadWriteLocked (info .ReadWriteLocked )
556
- lockedInfo .SetExists (info .Exists )
557
557
lockedInfo .SetSize (info .Size )
558
558
lockedInfo .SetMtime (info .Mtime )
559
559
lockedInfo .SetMode (info .Mode )
@@ -592,7 +592,7 @@ func GetLockedInfo(ctx context.Context, mountPoint filesystem.Provider, mappings
592
592
}
593
593
return
594
594
}
595
- lockedInfo .Exists = true
595
+ lockedInfo .SetExists ( true )
596
596
597
597
if rstIds == nil {
598
598
rstIds = entryInfo .Entry .Remote .RSTIDs
0 commit comments