From 250f85de6c174662aa135ef64b1c47bf165eaa66 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 4 Sep 2020 21:03:24 +0100 Subject: [PATCH] Fix atomicity of file reading in VFS. --- RomRepoMgr.Core/Filesystem/Vfs.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/RomRepoMgr.Core/Filesystem/Vfs.cs b/RomRepoMgr.Core/Filesystem/Vfs.cs index a2110f2..42e88b1 100644 --- a/RomRepoMgr.Core/Filesystem/Vfs.cs +++ b/RomRepoMgr.Core/Filesystem/Vfs.cs @@ -364,9 +364,12 @@ namespace RomRepoMgr.Core.Filesystem if(!_streamsCache.TryGetValue(handle, out Stream stream)) return -1; - stream.Position = offset; + lock(stream) + { + stream.Position = offset; - return stream.Read(buf, 0, buf.Length); + return stream.Read(buf, 0, buf.Length); + } } internal bool Close(long handle)