From: david-sarah Date: Tue, 25 May 2010 02:02:09 +0000 (-0700) Subject: SFTP: fix problem with posix-rename code returning a Deferred for the renamed filenod... X-Git-Tag: trac-4400~5 X-Git-Url: https://git.rkrishnan.org/components/architecture.txt?a=commitdiff_plain;h=8f86490d48957a46e4fa7492b2748e2a6f8afec5;p=tahoe-lafs%2Ftahoe-lafs.git SFTP: fix problem with posix-rename code returning a Deferred for the renamed filenode, not for the result of the request (an empty string). --- 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())