Skip to content

Commit

Permalink
Merge pull request #1285 from tdrwenski/zarr-last-modified
Browse files Browse the repository at this point in the history
Fix Zarr last modified
  • Loading branch information
tdrwenski authored Jan 17, 2024
2 parents b491750 + 4992256 commit bb69bbd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ private void makeVariable(RandomAccessDirectoryItem item, long dataOffset, ZArra

private List<Attribute> makeAttributes(RandomAccessDirectoryItem item) {
// get RandomAccessFile for JSON parsing
try (RandomAccessFile raf = item.getOrOpenRaf()) {
try {
RandomAccessFile raf = item.getOrOpenRaf();
// read attributes from file
raf.seek(0);
Map<String, Object> attrMap = objectMapper.readValue(raf, HashMap.class);
Expand Down
5 changes: 5 additions & 0 deletions cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrIosp.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,9 @@ private Object getFillValue(ZarrHeader.VInfo vinfo, DataType dataType) {
}
return fillValue;
}

@Override
public long getLastModified() {
return raf.getLastModified();
}
}
8 changes: 8 additions & 0 deletions cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,12 @@ public void testFillValues() throws IOException {
assertThat(double_ninf.getDouble(0)).isEqualTo(Double.NEGATIVE_INFINITY);
}

@Test
public void testLastModified() throws IOException {
for (String uri : stores) {
try (NetcdfFile ncfile = NetcdfFiles.open(uri)) {
assertThat(ncfile.getLastModified()).isNotEqualTo(0);
}
}
}
}

0 comments on commit bb69bbd

Please sign in to comment.