scijava-common icon indicating copy to clipboard operation
scijava-common copied to clipboard

DataHandleService creates a 0-length file to check if it exists?

Open BobHanson opened this issue 6 years ago • 1 comments

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?

BobHanson avatar Dec 30 '19 18:12 BobHanson

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.

BobHanson avatar Dec 31 '19 19:12 BobHanson