Juce File and creating directories on Samba shares

I’ve stumbled across weird bugs with Juce on Samba shares. If i create a directory and immediately create another directory or write an audio file inside it, weird things happen.

  1. Creating a directory under a new directory fails with error message “Cannot create a file when that file already exists”.
  2. Writing audio to a new (wav) file under the new directory corrupts the file.

In case 2, the data is actually correct, but the Windows filesystem thinks the wav file is now a directory and any attempt to access it fails with obscure error messages like “The directory name is invalid”. Copying the file in Windows to another location fixes it. Only the first audio file gets corrupt. The following files are just fine. In both cases the first File::createDirectory succeeds without an error result.

I suspected that the entry/record for the first directory has not been fully updated to the filesystem at the time the child file is created, and hacked a 100ms sleep after creating the directory - just to see what happens and guess what - according to my client the problem went away.

This looks to me like Juce is returning from File::createDirectory before it should. Has anyone any idea what could be the problem here?

I haven’t yet managed to get a setup for reproducing this in my development environment, so i only have reports from my client.

Can’t imagine what Juce could do more than call Win32 CreateDirectoryW though, which it does… doesn’t look like a Juce bug at all. Still, anyone had this problem on Windows and Samba?

I checked that the Samba share runs on an up to date Samba and has no weird configuration options and had another debug session on this.

What i’m trying to do now is to

  1. delete an existing directory and all of its contents
  2. create a new empty directory with the same name

I’ve taken the approach of first renaming the directory and deleting the renamed directory according to this:

Now creating the new directory seems to work, but deleting the renamed directory fails to remove the first content file, leaving the file and the renamed directory hanging as garbage. JUCE just returns false from File::deleteRecursively().