Skip to content

Commit 19903c4

Browse files
committed
refactor: don't explicitly handle the cache case in createGroup guard clauses, the normal calls handle this when it is cached
Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
1 parent 18702dc commit 19903c4

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,11 @@ default void createGroup(final String path) throws N5Exception {
5757
// avoid hitting the backend if this path is already a group according to the cache
5858
// else if exists is true (then a dataset is present) so throw an exception to avoid
5959
// overwriting / invalidating existing data
60-
if (cacheMeta()) {
61-
if (getCache().isGroup(normalPath, getAttributesKey()))
62-
return;
63-
else if (getCache().exists(normalPath, getAttributesKey())) {
64-
throw new N5Exception("Can't make a group on existing path.");
65-
}
66-
}
60+
if (groupExists(normalPath))
61+
return;
62+
else if (datasetExists(normalPath))
63+
throw new N5Exception("Can't make a group on existing dataset.");
6764

68-
// N5Writer.super.createGroup(path);
69-
/*
70-
* the lines below duplicate the single line above but would have to call
71-
* normalizeGroupPath again the below duplicates code, but avoids extra work
72-
*/
7365
getKeyValueAccess().createDirectories(absoluteGroupPath(normalPath));
7466

7567
if (cacheMeta()) {

0 commit comments

Comments
 (0)