Skip to content

Commit

Permalink
spring-projectsGH-9453: Correct separator when checking smb path
Browse files Browse the repository at this point in the history
Fixes: spring-projects#9453
Issue link: spring-projects#9453

On a smb file upload, to detect the need for new remote directories,
the remote path was checked for the local filesystem path separator.
On Windows that is \\ which is never found in a smb path, so the
necessary remote path was not created and the operation failed.

Use the correct separator which was already available as a
constant.
  • Loading branch information
pfosser committed Sep 12, 2024
1 parent 775bfd6 commit 0aad93a
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public class SmbSession implements Session<SmbFile> {

private static final LogAccessor logger = new LogAccessor(SmbSession.class);

private static final String FILE_SEPARATOR = FileSystems.getDefault().getSeparator();

private static final String SMB_FILE_SEPARATOR = "/";

private final SmbShare smbShare;
Expand Down Expand Up @@ -338,7 +336,7 @@ public boolean isDirectory(String _path) throws IOException {
* @throws IOException on error conditions returned by a CIFS server
*/
String mkdirs(String _path) throws IOException {
int idxPath = _path.lastIndexOf(FILE_SEPARATOR);
int idxPath = _path.lastIndexOf(SMB_FILE_SEPARATOR);
if (idxPath > -1) {
String path = _path.substring(0, idxPath + 1);
mkdir(path);
Expand Down

0 comments on commit 0aad93a

Please sign in to comment.