Skip to content

Commit 40c3884

Browse files
authored
Merge pull request #195 from JaneliaSciComp/check-zarrv3-before-zarrv2
fix: check zarrv3 before zarrv2
2 parents 4aea83f + 7e9c0f8 commit 40c3884

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/hooks/useZarrMetadata.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -156,44 +156,44 @@ export default function useZarrMetadata() {
156156
fileBrowserState.currentFileOrFolder.path
157157
);
158158

159-
const zarrayFile = getFile('.zarray');
160-
if (zarrayFile) {
161-
await checkZarrArray(imageUrl, 2, signal);
162-
} else {
163-
const zattrsFile = getFile('.zattrs');
164-
if (zattrsFile) {
165-
const attrs = (await fetchFileAsJson(
166-
fileBrowserState.currentFileSharePath.name,
167-
zattrsFile.path,
168-
cookies
169-
)) as any;
170-
if (signal.aborted) {
171-
return;
172-
}
173-
if (attrs.multiscales) {
174-
await checkOmeZarrMetadata(imageUrl, 2, signal);
159+
const zarrJsonFile = getFile('zarr.json');
160+
if (zarrJsonFile) {
161+
const attrs = (await fetchFileAsJson(
162+
fileBrowserState.currentFileSharePath.name,
163+
zarrJsonFile.path,
164+
cookies
165+
)) as any;
166+
if (signal.aborted) {
167+
return;
168+
}
169+
if (attrs.node_type === 'array') {
170+
await checkZarrArray(imageUrl, 3, signal);
171+
} else if (attrs.node_type === 'group') {
172+
if (attrs.attributes?.ome?.multiscales) {
173+
await checkOmeZarrMetadata(imageUrl, 3, signal);
174+
} else {
175+
log.info('Zarrv3 group has no multiscales', attrs.attributes);
175176
}
176177
} else {
177-
const zarrJsonFile = getFile('zarr.json');
178-
if (zarrJsonFile) {
178+
log.warn('Unknown Zarrv3 node type', attrs.node_type);
179+
}
180+
} else {
181+
const zarrayFile = getFile('.zarray');
182+
if (zarrayFile) {
183+
await checkZarrArray(imageUrl, 2, signal);
184+
} else {
185+
const zattrsFile = getFile('.zattrs');
186+
if (zattrsFile) {
179187
const attrs = (await fetchFileAsJson(
180188
fileBrowserState.currentFileSharePath.name,
181-
zarrJsonFile.path,
189+
zattrsFile.path,
182190
cookies
183191
)) as any;
184192
if (signal.aborted) {
185193
return;
186194
}
187-
if (attrs.node_type === 'array') {
188-
await checkZarrArray(imageUrl, 3, signal);
189-
} else if (attrs.node_type === 'group') {
190-
if (attrs.attributes?.ome?.multiscales) {
191-
await checkOmeZarrMetadata(imageUrl, 3, signal);
192-
} else {
193-
log.info('Zarrv3 group has no multiscales', attrs.attributes);
194-
}
195-
} else {
196-
log.warn('Unknown Zarrv3 node type', attrs.node_type);
195+
if (attrs.multiscales) {
196+
await checkOmeZarrMetadata(imageUrl, 2, signal);
197197
}
198198
}
199199
}

0 commit comments

Comments
 (0)