Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in SmbFiles mkdirs always causes STATUS_OBJECT_NAME_COLLISION #679

Closed
f-de opened this issue Nov 24, 2021 · 1 comment
Closed

Bug in SmbFiles mkdirs always causes STATUS_OBJECT_NAME_COLLISION #679

f-de opened this issue Nov 24, 2021 · 1 comment

Comments

@f-de
Copy link

f-de commented Nov 24, 2021

There is a bug in com.hierynomus.smbj.utils.SmbFiles mkdirs which always causes SMBApiException: STATUS_OBJECT_NAME_COLLISION. This method is supposed to check if a folder and its parents exist and create them otherwise. But it will try to create an already existing directory.

public void mkdirs(DiskShare diskShare, SmbPath path) throws SMBApiException {
	if (!diskShare.folderExists(path.getPath())) {
		// Ensure the parent path exists
		mkdirs(diskShare, path.getParent());
	}
	diskShare.mkdir(path.getPath());
}

This should be correct:

public void mkdirs(DiskShare diskShare, SmbPath path) throws SMBApiException {
	if (!diskShare.folderExists(path.getPath())) {
		// Ensure the parent path exists
		mkdirs(diskShare, path.getParent());
		diskShare.mkdir(path.getPath());
	}
}

The error was apparently introduced in this change:
5cf73b2#diff-dd81c4aafc6bf89377f022a5f6f2e7f471e39d82054313db1a7e91325cbea733

@hierynomus
Copy link
Owner

This should be fixed with #685

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants