aboutsummaryrefslogtreecommitdiff
path: root/weed/wdclient/vid_map.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/wdclient/vid_map.go')
-rw-r--r--weed/wdclient/vid_map.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.go
index 5c3d167db..7a2a5bb92 100644
--- a/weed/wdclient/vid_map.go
+++ b/weed/wdclient/vid_map.go
@@ -141,6 +141,19 @@ func (vc *vidMap) GetLocations(vid uint32) (locations []Location, found bool) {
return nil, false
}
+func (vc *vidMap) GetLocationsClone(vid uint32) (locations []Location, found bool) {
+ locations, found = vc.GetLocations(vid)
+
+ if found {
+ // clone the locations in case the volume locations are changed below
+ existingLocations := make([]Location, len(locations))
+ copy(existingLocations, locations)
+ return existingLocations, found
+ }
+
+ return nil, false
+}
+
func (vc *vidMap) getLocations(vid uint32) (locations []Location, found bool) {
vc.RLock()
defer vc.RUnlock()