Page 2 of 2

Re: preprocessing stuck at 99% if incomplete on smb3

Posted: May 15th, 2017, 2:18 pm
by sander
Let 's wait for @safihre (or maybe @shypike) what they say about the code, and why it is done like this. And after that consider solutions / workarounds.

BTW: What does Microsoft says about the exit code / resultcode of rmdir on directories. Nothing on https://technet.microsoft.com/en-us/lib ... 90990.aspx :-(

Re: preprocessing stuck at 99% if incomplete on smb3

Posted: May 15th, 2017, 3:34 pm
by defkev
I suppose the errorcode 9009 for rmdir on windows just means what rmdir reported, aka. "The directory is not empty."

The only rule of thumb which applies on all platforms dating back like forever is that your program should return 0 on a clean exit.
Only if something went fu it should return a non-zero code. What that is and how it translates into something "human readable" is pretty much up to whoever wrote the code.

Unfortunately Google doesn't give much of a explanation either, the topic is probably to generic.

But interessting how rmdir on two different platforms is acting in the exact same strange way and one of these platforms is from the same guys who are mainly responsible for the SMB protocol ;D

Re: preprocessing stuck at 99% if incomplete on smb3

Posted: May 15th, 2017, 3:35 pm
by sander
FWIW: I found this text on https://ss64.com/nt/rd.html ... so a difference between ERRORLEVEL (not set) and Exit Code.
Exit code / Errorlevel
In normal use RD will fail to return an ERRORLEVEL to the shell, irrespective if the command succeeds or fails the ERRORLEVEL will be left unchanged.

It will however set an Exit Code

Directory deleted successfully = 0
Invalid option = 1
Directory not found = 2
Access denied = 5
Directory in use = 32
Directory not empty = 145

A workaround to detect a non zero Exit Code from RD is to use conditional execution to run a command if the RD fails, the second command can be anything, an Echo, Goto or CALL statement:

RD NonExistentFolder || Echo This failed!
If you delete folders using PowerShell then a True/False return code ($?) will be set correctly.
EDIT

FWIW #2:

Python-on-Windows talking to the Windows-share seems to work correctly:

Code: Select all

Z:\>c:\python27\python -c "import os ; os.rmdir('Z:\\Downloads') "
Traceback (most recent call last):
  File "<string>", line 1, in <module>
WindowsError: [Error 145] The directory is not empty: 'Z:\\Downloads'
... so it's a problem when Samba and/or Linux is involved?

Re: preprocessing stuck at 99% if incomplete on smb3

Posted: May 18th, 2017, 6:31 am
by safihre
Back from holidays :)
So the reuse is triggered when a job is added again from history (if it failed, using Retry button) or when using the precheck.
Basically sabnzbd will treat it as a whole new job, if the pre check was successful.
So it seems to me that we can easily set keep_dir=True, since we want to keep that directory anyway.

Re: preprocessing stuck at 99% if incomplete on smb3

Posted: May 19th, 2017, 8:15 am
by safihre
Patched it.
Will be in 2.0.1.