From 83f94e1ef5989b1d24d08bdb4e7bd1db0e405dc2 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Fri, 24 Mar 2023 09:13:12 +0100 Subject: [PATCH] Fix concurrent map read and map write --- io/fs/mem.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/io/fs/mem.go b/io/fs/mem.go index 44295d78..dd7efd1a 100644 --- a/io/fs/mem.go +++ b/io/fs/mem.go @@ -355,7 +355,11 @@ func (fs *memFilesystem) Symlink(oldname, newname string) error { func (fs *memFilesystem) WriteFileReader(path string, r io.Reader) (int64, bool, error) { path = fs.cleanPath(path) - if fs.isDir(path) { + fs.filesLock.Lock() + isdir := fs.isDir(path) + fs.filesLock.Unlock() + + if isdir { return -1, false, fmt.Errorf("path not writeable") }