Skip to content

Commit 5a8fea7

Browse files
committed
vdi_info_of_vdi_rec: use try-with and List.assoc
Signed-off-by: Gabor Igloi <[email protected]>
1 parent 7c01ae3 commit 5a8fea7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ocaml/xapi/storage_access.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ let find_content ~__context ?sr name =
6767

6868
let vdi_info_of_vdi_rec __context vdi_rec =
6969
let content_id =
70-
if List.mem_assoc "content_id" vdi_rec.API.vDI_other_config
71-
then List.assoc "content_id" vdi_rec.API.vDI_other_config
72-
else vdi_rec.API.vDI_location (* PR-1255 *)
70+
try
71+
List.assoc "content_id" vdi_rec.API.vDI_other_config
72+
with Not_found -> vdi_rec.API.vDI_location (* PR-1255 *)
7373
in {
7474
vdi = vdi_rec.API.vDI_location;
7575
uuid = Some vdi_rec.API.vDI_uuid;

0 commit comments

Comments
 (0)