From 8f86490d48957a46e4fa7492b2748e2a6f8afec5 Mon Sep 17 00:00:00 2001 From: david-sarah Date: Mon, 24 May 2010 19:02:09 -0700 Subject: [PATCH] SFTP: fix problem with posix-rename code returning a Deferred for the renamed filenode, not for the result of the request (an empty string). --- src/allmydata/frontends/sftpd.py | 6 ++++-- src/allmydata/test/test_sftp.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/allmydata/frontends/sftpd.py b/src/allmydata/frontends/sftpd.py index c768fd7a..ccf05b24 100644 --- a/src/allmydata/frontends/sftpd.py +++ b/src/allmydata/frontends/sftpd.py @@ -93,7 +93,7 @@ def _convert_error(res, request): logmsg("RAISE %r %r" % (request, err.value), level=OPERATIONAL) try: if noisy: logmsg(traceback.format_exc(err.value), level=NOISY) - except: + except: # pragma: no cover pass # The message argument to SFTPError must not reveal information that @@ -1398,7 +1398,9 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin): fromPathstring = extensionData[4:(4 + fromPathLen)] toPathstring = extensionData[(8 + fromPathLen):] - return self.renameFile(fromPathstring, toPathstring, overwrite=True) + d = self.renameFile(fromPathstring, toPathstring, overwrite=True) + d.addCallback(lambda ign: "") + return d if extensionName == 'statvfs@openssh.com' or extensionName == 'fstatvfs@openssh.com': return defer.succeed(struct.pack('>11Q', diff --git a/src/allmydata/test/test_sftp.py b/src/allmydata/test/test_sftp.py index 1b4a9032..84d2c8ad 100644 --- a/src/allmydata/test/test_sftp.py +++ b/src/allmydata/test/test_sftp.py @@ -1009,7 +1009,9 @@ class Handler(GridTestMixin, ShouldFailMixin, unittest.TestCase): def _renameFile(fromPathstring, toPathstring): extData = (struct.pack('>L', len(fromPathstring)) + fromPathstring + struct.pack('>L', len(toPathstring)) + toPathstring) - return self.handler.extendedRequest('posix-rename@openssh.com', extData) + d2 = self.handler.extendedRequest('posix-rename@openssh.com', extData) + d2.addCallback(lambda res: self.failUnlessReallyEqual(res, "")) + return d2 d = self._set_up("renameFile_posix") d.addCallback(lambda ign: self._set_up_tree()) -- 2.45.2