Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] Fix concurrent map writes in file copy

Neeraj Gupta266f374af93f
diff --git a/server/pkg/controller/file_copy/file_copy.go b/server/pkg/controller/file_copy/file_copy.go
index 0d718f4264..4c785dbd90 100644
--- a/server/pkg/controller/file_copy/file_copy.go
+++ b/server/pkg/controller/file_copy/file_copy.go
@@ -139,6 +139,7 @@ func (fc *FileCopyController) CopyFiles(c *gin.Context, req ente.CopyFileSyncReq
fileCopyList = append(fileCopyList, fileCopy)
}
oldToNewFileIDMap := make(map[int64]int64)
+ var mapMutex sync.Mutex
var wg sync.WaitGroup
errChan := make(chan error, len(fileCopyList))
@@ -151,7 +152,9 @@ func (fc *FileCopyController) CopyFiles(c *gin.Context, req ente.CopyFileSyncReq
errChan <- err
return
}
+ mapMutex.Lock()
oldToNewFileIDMap[fileCopy.SourceFile.ID] = newFile.ID
+ mapMutex.Unlock()
}(fileCopy)
}