Repository navigation
Closed
Milestone
Description
Steps to reproduce
- Mount SFTP storage to "/sftp"
- Setup sync client
- Wait for sync
- Create a local empty file "/sftp/empty" (I used
touch) - Wait for sync
Expected result
Upload success
Actual result
{"reqId":"xfcr9w7zcMtDujLalJUL","remoteAddr":"127.0.0.1","app":"webdav","message":"Exception: {\"Message\":\"HTTP\\\/1.1 500 Could not rename part file to final file\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/connector\\\/sabre\\\/directory.php(111): OC\\\\Connector\\\\Sabre\\\\File->put(Resource id #241)\\n#1 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1053): OC\\\\Connector\\\\Sabre\\\\Directory->createFile('empty2', Resource id #241)\\n#2 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(513): Sabre\\\\DAV\\\\Server->createFile('sftp\\\/empty2', Resource id #241, NULL)\\n#3 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpPut(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#5 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(469): Sabre\\\\Event\\\\EventEmitter->emit('method:PUT', Array)\\n#6 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#7 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/apps\\\/files\\\/appinfo\\\/remote.php(83): Sabre\\\\DAV\\\\Server->exec()\\n#8 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/remote.php(84): require_once('\\\/srv\\\/www\\\/htdocs...')\\n#9 {main}\",\"File\":\"\\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/connector\\\/sabre\\\/file.php\",\"Line\":211}","level":4,"time":"2015-06-18T16:06:41+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/sftp\/empty2"}
Versions
Observed on ownCloud 8.1 git master (7a0917e)
Activity
PVince81 commentedon Jun 18, 2015
It looks like the part file is not being created on the SFTP storage, so the final rename cannot work.
It works fine for non-empty files.
PVince81 commentedon Jun 18, 2015
Also broken on stable8.
I suspect that the phpseclib doesn't create the file remotely until the first block is sent.
We might want to work this around by calling file_put_contents without content instead of fopen.
Strangely it works in the web UI, I'll try and compare the code paths.
PVince81 commentedon Jun 22, 2015
CC @bantu in case you have an idea regarding phpseclib
bantu commentedon Jun 22, 2015
@PVince81 I can look into it, if you want. Can you get me a complete trace?
PVince81 commentedon Jun 24, 2015
Ok, the reason why it works in the web UI is because newfile.php does a "touch()" instead of "file_put_contents()".
Here is a stack from when creating an empty file:
If you look at the code, there is no actual instruction sent to the SFTP server to create an empty file when calling fopen() in write mode: https://github.com/owncloud/3rdparty/blob/master/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php#L270
Note that it does not enter the block with
truncate()because$this->size === falseis true, so it goes to the block above.bantu commentedon Jun 24, 2015
@PVince81 An fopen() followed by an fclose() should be sufficient to create a file, IMO. I've constructed a test case at phpseclib/phpseclib#713
PVince81 commentedon Jun 25, 2015
Hmm, are you saying that maybe the upload code isn't closing the file properly ?
bantu commentedon Jun 25, 2015
@PVince81 No. This clearly seems to be a bug in phpseclib. The test case above reproduces the behaviour. An fopen followed by an fclose does not result in the file being created.
PVince81 commentedon Jun 25, 2015
Ok thanks for the info.
So we'll need to put a workaround in the meantime.
bantu commentedon Jun 25, 2015
@PVince81 phpseclib/phpseclib#713 Contains a possible fix now, if you want to test and confirm.
PVince81 commentedon Jun 25, 2015
I won't have time to fix this for 8.1. Still busy with many other issues.
Removing assignment for now.
PVince81 commentedon Jul 7, 2015
Ok let's upgrade phpseclib then for 8.2.
8.1.1 might need a workaround.
PVince81 commentedon Jul 7, 2015
@bantu phpseclib has a tag 0.3.10 which I could upgrade to, but the PR says 2.0. Do I need to wait for version 2.0 to be released ?
bantu commentedon Jul 7, 2015
@PVince81 There have been many fixes in phpseclib recently. I think phpseclib should make a release soon you can then upgrade to. Possibly 0.3.11.
RobinMcCorkell commentedon Sep 13, 2015
phpseclib is now version 2.0 in master, can this be closed?
karlitschek commentedon Sep 14, 2015
@Xenopathic have you tested if the original issue is solved?
PVince81 commentedon Sep 22, 2015
Tested on master, works now. Closing.