FarManager icon indicating copy to clipboard operation
FarManager copied to clipboard

0x000000B7 - Cannot create a file when that file already exists.

Open ghost opened this issue 4 years ago • 33 comments

Cannot copy to network share (samba).

If I press ESC I can see created directory.

After that I can try copying again (F5) and it works.

Windows Explorer works fine.

ghost avatar Mar 05 '21 20:03 ghost

When you'll get an error, press F3, copy all the content from appeared window, and paste it here

Pxx64 avatar Mar 07 '21 09:03 Pxx64

@Pxx64

image

ghost avatar Mar 22 '21 12:03 ghost

Which Far build you are on? I recall there was similar bug fixed some time ago, please try the latest Nightly build from https://farmanager.com/download.php?l=en, and I can't reproduce the issue on my Samba share. In case if its reproducible for you on the latest build, please provide full steps to reproduce the issue, including Samba version and share configuration.

Pxx64 avatar Mar 22 '21 18:03 Pxx64

Nightly is also affected.

Do all using far manager.

  1. Create some directory on samba share: for example Test.
  2. Copy this directory to local disk on Windows machine.
  3. Delete Test directory at samba share.
  4. Try to copy Test directory from local disk to samba share.
  5. Error

ghost avatar Mar 24 '21 15:03 ghost

Unfortunately, not reproducible for me. Which Samba version you are running? I'm on 4.13.1 now How the share is configured, any non-standard ACLs?

Pxx64 avatar Mar 25 '21 00:03 Pxx64

Btw, did you try with a clean profile? Just unpack nightly into separate folder, rename Far.exe.example.ini to Far.exe.ini, open it, uncomment and set UseSystemProfiles=0 save it, and then run Far from that folder

Pxx64 avatar Mar 25 '21 00:03 Pxx64

@alabuzhev I assume memory dump at the point when the error is appearing would be useless for debug, need to capture stacks before that with ttd or wpr/xperf?

Pxx64 avatar Mar 25 '21 00:03 Pxx64

@Pxx64, we try to call CreateDirectoryEx first (to inherit as much data as possible from the source directory), and, if it fails, we fall back to CreateDirectory.

Supposedly, CreateDirectoryEx is not a transactional operation within samba: first it creates it, then it tries to set some attributes and fails, not cleaning after itself and leaving the directory there as is, in a semi-created state. A subsequent CreateDirectory call fails because it's already there. We could probably workaround it, but someone needs to confirm first - all this is a pure speculation.

alabuzhev avatar Mar 25 '21 02:03 alabuzhev

A dump will be useless indeed.

alabuzhev avatar Mar 25 '21 02:03 alabuzhev

Please run this - gh-368.zip, e.g. test.exe C:\some_folder \\server\share\some_folder and show the output.

alabuzhev avatar Mar 25 '21 17:03 alabuzhev

Which Far build you are on? I recall there was similar bug fixed some time ago, please try the latest Nightly build from https://farmanager.com/download.php?l=en, and I can't reproduce the issue on my Samba share. In case if its reproducible for you on the latest build, please provide full steps to reproduce the issue, including Samba version and share configuration.

Samba 4.12.12 (fc32, latest rpm from stable)

ghost avatar Mar 25 '21 21:03 ghost

Please run this - gh-368.zip, e.g. test.exe C:\some_folder \\server\share\some_folder and show the output.

CreateDirectoryEx failed with 183
Z:\Storage\Test exists after the failure

183 is ERROR_ALREADY_EXISTS (cannot create a file when that file already exists).

And directory is created by Win32 API. Is it a bug in API? Samba?
It does not look like a bug in Far Manager considering all above.

Workaround is easy I think, you can make a check like this one GetFileAttributes(dst) before 2nd attempt to create directory.

ghost avatar Mar 25 '21 22:03 ghost

This confirms the assumption above. 🤦‍♂️

And directory is created by Win32 API. Is it a bug in API? Samba?

Samba of course. Win32 just forwards the command to the underlying drivers, network protocols etc. It looks like the classic "let's implement 53% of each spec and then hope that no app tries to do certain things in a certain way".

Try 9ae1a95 / 5769.

alabuzhev avatar Mar 25 '21 22:03 alabuzhev

Try 9ae1a95 / 5769.

For first look all works fine!

Thanks ))

ghost avatar Mar 26 '21 02:03 ghost

Samba of course.

Just some thoughts. I have used robocopy and installed some other managers like Double Commander.

Windows Explorer , Robocopy, Drag&Drop in FileZilla, Double Commander are not affected by this issue.

Though on Win7 only Far and Robocopy use SMB2 FSCTL_SRV_COPYCHUNK.

ghost avatar Mar 26 '21 02:03 ghost

Samba of course.

Just some thoughts. I have used robocopy and installed some other managers like Double Commander.

Windows Explorer , Robocopy, Drag&Drop in FileZilla, Double Commander are not affected by this issue.

Though on Win7 only Far and Robocopy use SMB2 FSCTL_SRV_COPYCHUNK.

On the other hand, I've been writing daily to samba shares with Far, on both ArchLinux and Alpine servers for years, and I don't remember ever encountering this issue.

bitraid avatar Mar 26 '21 06:03 bitraid

Samba of course.

Just some thoughts. I have used robocopy and installed some other managers like Double Commander. Windows Explorer , Robocopy, Drag&Drop in FileZilla, Double Commander are not affected by this issue. Though on Win7 only Far and Robocopy use SMB2 FSCTL_SRV_COPYCHUNK.

On the other hand, I've been writing daily to samba shares with Far, on both ArchLinux and Alpine servers for years, and I don't remember ever encountering this issue.

You need to do exact steps to reproduce the issue. Directory which you want to copy to samba should came originally from the same samba. For example, copy from samba to samba also fails if it is made with Far on windows.

Maybe I can try different live distros and mount partitions manually to finally find the reason.
But I afraid we will spend a lot of time in attempts to find it.
I will try but workaround for Far works fine ))

ghost avatar Mar 26 '21 15:03 ghost

You need to do exact steps to reproduce the issue. I did that, and it is not reproducible for me, same with "copy from samba to samba also fails if it is made with Far on windows.", both files and folders are copied fine, so this is either Samba 4.12 issue, or Fedora issue, or both, or config, or... )))

Pxx64 avatar Mar 26 '21 18:03 Pxx64

You need to do exact steps to reproduce the issue. I did that, and it is not reproducible for me, same with "copy from samba to samba also fails if it is made with Far on windows.", both files and folders are copied fine, so this is either Samba 4.12 issue, or Fedora issue, or both, or config, or... )))

@Pxx64 Windows 7?

ghost avatar Mar 26 '21 21:03 ghost

Yes

Pxx64 avatar Mar 26 '21 21:03 Pxx64

Anything else here / can we close it?

alabuzhev avatar Apr 12 '21 18:04 alabuzhev

Anything else here / can we close it?

Yes

ghost avatar Apr 22 '21 10:04 ghost

@alabuzhev I am still getting it in 5800 build. No merged fixes?

ghost avatar May 20 '21 09:05 ghost

@hardhub the fix is merged of course. If you still getting it, it's probably some slightly different issue, not covered by the fix.

alabuzhev avatar May 20 '21 09:05 alabuzhev

I will have to repeat tests mentioned above and check what happens.

ghost avatar May 20 '21 11:05 ghost

@alabuzhev Hi, I think I have found the information which can help. The same problem repeats if source directory is located on another samba share (at least if it is same samba server, but different shares).

So probably not all code paths are covered.

ghost avatar Oct 01 '21 04:10 ghost

I have test once again with the tool from above comment and result is the same:

CreateDirectoryEx failed with 183
Z:\Some\Directory exists after the failure

ghost avatar Oct 01 '21 05:10 ghost

@hardhub Please provide exact steps to reproduce it, what you see, what you expect, versions etc.

alabuzhev avatar Oct 01 '21 22:10 alabuzhev

@alabuzhev It is hard to get exact steps. But I will try explain how it happens.

I have 2 network drivers mounted from 2 different samba shares on the same PC (protocol version SMB2_10).
I start copying from one drive to another.
I select multiple directories in Y:\Some\Nested\Path and copy all to Z:\Some\Nested\Path
First chosen directory copied well (selection is cleared), but before copying 2nd one I get the error.
Original issue was possible to reproduce much easier but current variant needs copying some files before it to occurs.

Usually I copy video files such way from one location to another.
And files are not transferred to client machine, it was copied fully on the server side (with the speed of disk array).

ghost avatar Oct 02 '21 07:10 ghost

If you need more information let me know what I need to check.

ghost avatar Oct 02 '21 07:10 ghost