I can't get .exists() or .isDirectory() to return true for a subfolder that exists, from which I can .listFiles() and get the expected result.
subfolder = createSmbFile("smb://my-server/uploads/subfolder");
log.debug(subfolder.exists() + "/" + subfolder.isDirectory());
produces "false/false". Yet calling .listFiles() would return an array of [file1, file2, file3...]. I've been able to implement uploading and downloading of specific files by name (ending with an extension) without issue.
What am I doing wrong?
Edit: This is my jcifs version btw
<dependency>
<groupId>eu.agno3.jcifs</groupId>
<artifactId>jcifs-ng</artifactId>
<version>2.1.4</version>
</dependency>
The problem seems to have been that the SmbFile#uncPath() was my-server/uploads/subfolder
, not my-server/subfolder
, as despite the hierarchical relationship between servers/filesystems, methods like exists() and isHidden() don't work like one might expect, and instead always return false.
Debugging through it and looking at the SmbFile's fileLocator property showed this.
It was explained here.