From d13621e63112ddf6417dac05f2c96ada1e9feb25 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 25 Mar 2024 16:50:48 +0100 Subject: [PATCH] Skip `CloseFileHandles` if file is not in use --- Source/Engine/Content/Storage/FlaxStorage.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Content/Storage/FlaxStorage.cpp b/Source/Engine/Content/Storage/FlaxStorage.cpp index 74b114f52..674330f70 100644 --- a/Source/Engine/Content/Storage/FlaxStorage.cpp +++ b/Source/Engine/Content/Storage/FlaxStorage.cpp @@ -1336,6 +1336,11 @@ FileReadStream* FlaxStorage::OpenFile() bool FlaxStorage::CloseFileHandles() { + // Early out if no handles are opened + Array streams; + _file.GetValues(streams); + if (streams.IsEmpty() && Platform::AtomicRead(&_chunksLock) == 0) + return false; PROFILE_CPU(); // Note: this is usually called by the content manager when this file is not used or on exit @@ -1367,7 +1372,7 @@ bool FlaxStorage::CloseFileHandles() return true; // Failed, someone is still accessing the file // Close file handles (from all threads) - Array streams; + streams.Clear(); _file.GetValues(streams); for (FileReadStream* stream : streams) {