Skip to content

Commit 8ddf90c

Browse files
authored
Merge pull request #280 from NeurodataWithoutBorders/279-fix-ignorecache
nwbRead now ignores .specloc and its target
2 parents 96bbb7e + 8997b4d commit 8ddf90c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

nwbRead.m

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@
2222
'groups', {{}});
2323
validateattributes(filename, {'char', 'string'}, {'scalartext', 'nonempty'});
2424

25-
if ~ignoreCache
26-
specLocation = checkEmbeddedSpec(filename);
27-
if ~isempty(specLocation)
28-
Blacklist.groups{end+1} = specLocation;
29-
end
25+
specLocation = getEmbeddedSpec(filename);
26+
if ~isempty(specLocation)
27+
Blacklist.groups{end+1} = specLocation;
28+
end
29+
30+
if ~ignoreCache && ~isempty(specLocation)
31+
generateSpec(filename, h5info(filename, specLocation));
32+
rehash(); % required if we want parseGroup to read the right files.
3033
end
3134

3235
nwb = io.parseGroup(filename, h5info(filename), Blacklist);
3336
end
3437

35-
function specLocation = checkEmbeddedSpec(filename)
38+
function specLocation = getEmbeddedSpec(filename)
3639
specLocation = '';
3740
fid = H5F.open(filename);
3841
try
@@ -41,24 +44,18 @@
4144
referenceRawData = H5A.read(attributeId);
4245
specLocation = H5R.get_name(attributeId, 'H5R_OBJECT', referenceRawData);
4346
H5A.close(attributeId);
44-
generateSpec(fid, h5info(filename, specLocation));
4547
catch ME
4648
if ~strcmp(ME.identifier, 'MATLAB:imagesci:hdf5lib:libraryError')
4749
rethrow(ME);
48-
end
49-
50-
attributeId = H5A.open(fid, 'nwb_version');
51-
version = H5A.read(attributeId);
52-
H5A.close(attributeId);
53-
54-
generateCore(version);
50+
end % don't error if the attribute doesn't exist.
5551
end
56-
rehash(); % required if we want parseGroup to read the right files.
52+
5753
H5F.close(fid);
5854
end
5955

60-
function generateSpec(fid, specinfo)
56+
function generateSpec(filename, specinfo)
6157
specNames = cell(size(specinfo.Groups));
58+
fid = H5F.open(filename);
6259
for i=1:length(specinfo.Groups)
6360
location = specinfo.Groups(i).Groups(1);
6461

@@ -88,6 +85,8 @@ function generateSpec(fid, specinfo)
8885
Namespace = spec.generate(namespaceText, schemaMap);
8986
specNames{i} = Namespace.name;
9087
end
88+
H5F.close(fid);
89+
fid = [];
9190

9291
missingNames = cell(size(specNames));
9392
for i = 1:length(specNames)

0 commit comments

Comments
 (0)