Merge lp:~mwhudson/launchpad/dont-oops-sftp-unlink-directory-bug-372506 into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/dont-oops-sftp-unlink-directory-bug-372506
Merge into: lp:launchpad
Diff against target: 29 lines
2 files modified
lib/lp/codehosting/sftp.py (+1/-0)
lib/lp/codehosting/tests/test_sftp.py (+7/-0)
To merge this branch: bzr merge lp:~mwhudson/launchpad/dont-oops-sftp-unlink-directory-bug-372506
Reviewer Review Type Date Requested Status
Paul Hummer (community) Approve
Review via email: mp+14127@code.launchpad.net

Commit message

Catch the error raised by transports when you try to delete() a directory to avoid logging an entirely spurious oops.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hi,

This fixes a simple oops bug: delete('path/to/directory') on a bzr Transport raises an exception we didn't know how to translate, leading to an oops being logged.

Cheers,
mwh

Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/codehosting/sftp.py'
2--- lib/lp/codehosting/sftp.py 2009-06-25 04:06:00 +0000
3+++ lib/lp/codehosting/sftp.py 2009-10-29 01:05:25 +0000
4@@ -429,6 +429,7 @@
5 bzr_errors.NoSuchFile: filetransfer.FX_NO_SUCH_FILE,
6 bzr_errors.FileExists: filetransfer.FX_FILE_ALREADY_EXISTS,
7 bzr_errors.DirectoryNotEmpty: filetransfer.FX_FAILURE,
8+ bzr_errors.TransportError: filetransfer.FX_FAILURE,
9 FileIsADirectory: filetransfer.FX_FILE_IS_A_DIRECTORY,
10 }
11 # Bazaar expects makeDirectory to fail with exactly the string "mkdir
12
13=== modified file 'lib/lp/codehosting/tests/test_sftp.py'
14--- lib/lp/codehosting/tests/test_sftp.py 2009-06-25 04:06:00 +0000
15+++ lib/lp/codehosting/tests/test_sftp.py 2009-10-29 01:05:25 +0000
16@@ -455,6 +455,13 @@
17 deferred = self.sftp_server.removeFile(filename)
18 return self.assertFailure(deferred, filetransfer.SFTPError)
19
20+ def test_removeFile_directory(self):
21+ # Errors in removeFile are translated into SFTPErrors.
22+ filename = self.getPathSegment()
23+ self.build_tree_contents([(filename+'/',)])
24+ deferred = self.sftp_server.removeFile(filename)
25+ return self.assertFailure(deferred, filetransfer.SFTPError)
26+
27 def test_renameFile(self):
28 # renameFile renames the file.
29 orig_filename = self.getPathSegment()