Skip to content

Commit 90ddf5d

Browse files
committed
fix: setDatasetAttributes no long overwrites user attributes
* add a test
1 parent a3e707b commit 90ddf5d

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/main/java/org/janelia/saalfeldlab/n5/N5Writer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ default void setDatasetAttributes(
142142
final String datasetPath,
143143
final DatasetAttributes datasetAttributes) throws N5Exception {
144144

145-
setAttribute(datasetPath, "/", getConvertedDatasetAttributes(datasetAttributes));
145+
setAttributes(datasetPath, getConvertedDatasetAttributes(datasetAttributes).asMap());
146146
}
147147

148148
/**

src/test/java/org/janelia/saalfeldlab/n5/AbstractN5Test.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,21 @@ public void testAttributes() {
771771
}
772772
}
773773

774+
@Test
775+
public void testDatasetAttributes() {
776+
777+
final String dset = "";
778+
final String key = "user-attr";
779+
final String value = "value";
780+
try (final N5Writer n5 = createTempN5Writer()) {
781+
782+
n5.setAttribute(dset, key, value);
783+
n5.setDatasetAttributes(dset, new DatasetAttributes(new long[]{5}, new int[]{5}, DataType.INT32));
784+
assertNotNull(n5.getDatasetAttributes(dset));
785+
assertEquals(value, n5.getAttribute(dset, key, String.class));
786+
}
787+
}
788+
774789
@Test
775790
public void testNullAttributes() throws URISyntaxException, IOException {
776791

0 commit comments

Comments
 (0)