From 695a05b262dc685c4ebf842433563d13a995f348 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Wed, 10 Jan 2024 13:01:07 +0100 Subject: [PATCH] BUGFIX: Prevent corrupting all files when no UUID is yet stored in a file --- python_src/lasp/lasp_measurement.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python_src/lasp/lasp_measurement.py b/python_src/lasp/lasp_measurement.py index 09a2151..47b0093 100644 --- a/python_src/lasp/lasp_measurement.py +++ b/python_src/lasp/lasp_measurement.py @@ -986,7 +986,13 @@ class Measurement: """ # See if the base part of the filename is referring to a file that is already open with h5.File(fn, 'r') as f: - uuid = f.attrs['UUID'] + try: + uuid = f.attrs['UUID'] + except AttributeError: + # No UUID stored in measurement. This is an old measurement that did not have UUID's + # We create a new UUID here such that the file is opened from the filesystem + # anyhow. + uuid = str(uuid.uuid1()) if uuid in Measurement.uuid_s.keys(): return Measurement.uuid_s[uuid]