2018-02-26, 22:20
Hi,
I use some code that copies subtitles from location (in this case network share) to local storage, process it, and copies result back to network share.
The original code looks like this:
While it works 100% when copying from smb: share to special://temp, on my machines it happens that copying from special://temp back to smb: fails, and success flag is set to 0.
For debug purposes I changed the code to:
This code has the same problem, but as the result I can see that file is correctly read from special://temp, and on target smb: the file is created in this case, but its length is 0. More of it, the result is 1.
The problem is that this behavior is not consistent between tries. It works ~90% of the time on my smb: share - both from Libreelec HTPC and Linux.
One of users reports that on nfs: share the first piece of code does not work at all - always fails to copy file back to share.
As xbmcvfs class is some wrapper built on top of cpp low level functions - is there any way to check what is the exact reason that xbmcvfs.copy() function fails (more than just binary result)?
I use some code that copies subtitles from location (in this case network share) to local storage, process it, and copies result back to network share.
The original code looks like this:
python:if xbmcvfs.exists(srcFile):
Log("copy_file: srcFile exists.")
if xbmcvfs.exists(dstFile):
delete_file(dstFile)
else:
Log("copy_file: dstFile does not exist.")
success = xbmcvfs.copy(srcFile, dstFile)
While it works 100% when copying from smb: share to special://temp, on my machines it happens that copying from special://temp back to smb: fails, and success flag is set to 0.
For debug purposes I changed the code to:
python:filehandle = xbmcvfs.File(srcFile)
buffer = filehandle.read()
filehandle.close()
Log("File data read: " + str(buffer))
filehandle = xbmcvfs.File(dstFile, 'w')
result = filehandle.write(buffer)
filehandle.close()
Log("File data write result: " + str(result))
This code has the same problem, but as the result I can see that file is correctly read from special://temp, and on target smb: the file is created in this case, but its length is 0. More of it, the result is 1.
The problem is that this behavior is not consistent between tries. It works ~90% of the time on my smb: share - both from Libreelec HTPC and Linux.
One of users reports that on nfs: share the first piece of code does not work at all - always fails to copy file back to share.
As xbmcvfs class is some wrapper built on top of cpp low level functions - is there any way to check what is the exact reason that xbmcvfs.copy() function fails (more than just binary result)?