Skip to content

Commit b44bac5

Browse files
committed
The client needs to read metadata from the original location, not the destination
1 parent baba743 commit b44bac5

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

src/murfey/client/contexts/spa_metadata.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,18 @@ def post_transfer(
126126
]["#text"]
127127
visit_index = windows_path.split("\\").index(environment.visit)
128128
partial_path = "/".join(windows_path.split("\\")[visit_index + 1 :])
129-
visitless_path = Path(
130-
str(transferred_file).replace(f"/{environment.visit}", "")
131-
)
132-
visit_index_of_transferred_file = transferred_file.parts.index(
133-
environment.visit
134-
)
129+
130+
source = _get_source(transferred_file, environment)
131+
if not source:
132+
logger.warning(
133+
f"Source could not be indentified for {str(transferred_file)}"
134+
)
135+
return
136+
137+
source_visit_dir = source.parent
138+
135139
atlas_xml_path = list(
136-
(
137-
Path(
138-
"/".join(
139-
transferred_file.parts[
140-
: visit_index_of_transferred_file + 1
141-
]
142-
)
143-
)
144-
/ partial_path
145-
).parent.glob("Atlas_*.xml")
140+
(source_visit_dir / partial_path).parent.glob("Atlas_*.xml")
146141
)[0]
147142
with open(atlas_xml_path, "rb") as atlas_xml:
148143
atlas_xml_data = xmltodict.parse(atlas_xml)
@@ -153,10 +148,6 @@ def post_transfer(
153148
# need to calculate the pixel size of the downscaled image
154149
atlas_pixel_size = atlas_original_pixel_size * 7.8
155150

156-
source = _get_source(
157-
visitless_path.parent / "Images-Disc1" / visitless_path.name,
158-
environment,
159-
)
160151
sample = None
161152
for p in partial_path.split("/"):
162153
if p.startswith("Sample"):

0 commit comments

Comments
 (0)