Keep one snapshot per session instead of one globally
Indexing used to discard every existing snapshot, so concurrent users wiped out each other's landscapes. Only the same session's previous snapshot and workspace are replaced now.
This commit is contained in:
@@ -519,13 +519,15 @@ func (s *Server) indexJob(id, root string) {
|
||||
s.jobsMu.Unlock()
|
||||
snapshot.ID = uniqueID("snapshot")
|
||||
|
||||
// Only the latest snapshot is kept; older workspaces are deleted.
|
||||
// Each session keeps only its latest snapshot; its older workspaces are deleted.
|
||||
s.snapshotsMu.Lock()
|
||||
var oldRoots []string
|
||||
for _, old := range s.snapshots {
|
||||
oldRoots = append(oldRoots, old.Root)
|
||||
for key, old := range s.snapshots {
|
||||
if old.Owner == snapshot.Owner {
|
||||
oldRoots = append(oldRoots, old.Root)
|
||||
delete(s.snapshots, key)
|
||||
}
|
||||
}
|
||||
clear(s.snapshots)
|
||||
s.snapshots[snapshot.ID] = snapshot
|
||||
s.snapshotsMu.Unlock()
|
||||
for _, old := range oldRoots {
|
||||
|
||||
Reference in New Issue
Block a user