scijava-common
scijava-common copied to clipboard
DataHandleService creates a 0-length file to check if it exists?
Do I read this correctly?
default boolean exists(final Location location) throws IOException {
try (DataHandle<Location> handle = create(location)) {
return handle == null ? false : handle.exists();
}
}
But that creates a 0-length file, which then exists. What am I missing?
Sorry, that was in org.scijava.handle.DataHandleService
I hacked this by changing org.scijava.plugin.WrapperService. :
default <D extends DT> PT create(final D data) {
final PT instance = find(data);
if (instance != null) instance.set(data);
if (instance instanceof FileHandle)
return ((FileHandle) instance).exists() ? instance : null;
return instance;
}
But, of course, that's not a "create" then, is it?
So I do not know what the proper fix is for this.