Skip to content

Commit

Permalink
move handle value check further up CloseFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Dabnsky committed Jun 11, 2024
1 parent 150b089 commit 3af706f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions component/file_cache/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,12 @@ func (fc *FileCache) OpenFile(options internal.OpenFileOptions) (*handlemap.Hand
func (fc *FileCache) CloseFile(options internal.CloseFileOptions) error {
log.Trace("FileCache::CloseFile : name=%s, handle=%d", options.Handle.Path, options.Handle.ID)

// if file has not been interactively read or written to by end user, then there is no cached file to close.
_, found := options.Handle.GetValue("openFileOptions")
if found {
return nil
}

localPath := common.JoinUnixFilepath(fc.tmpPath, options.Handle.Path)

err := fc.FlushFile(internal.FlushFileOptions{Handle: options.Handle}) //nolint
Expand All @@ -881,12 +887,6 @@ func (fc *FileCache) CloseFile(options internal.CloseFileOptions) error {
return err
}

// if file has not been interactively read or written to by end user, then there is no cached file to close.
_, found := options.Handle.GetValue("openFileOptions")
if found {
return nil
}

f := options.Handle.GetFileObject()
if f == nil {
log.Err("FileCache::CloseFile : error [missing fd in handle object] %s", options.Handle.Path)
Expand Down

0 comments on commit 3af706f

Please sign in to comment.