Ticket #4909: diff.patch
| File diff.patch, 2.3 KB (added by bigjools, 2 years ago) |
|---|
-
twisted/test/test_ftp.py
422 422 d2.addErrback(eb) 423 423 return defer.gatherResults([d1, d2]) 424 424 425 def test_STORwriteError(self): 426 """ 427 Any errors during writing a file inside a STOR should be returned to 428 the client. 429 """ 430 # Make a failing file writer. 431 class FailingFileWriter(ftp._FileWriter): 432 def receive(self): 433 return defer.fail(ftp.IsNotADirectoryError("blah")) 425 434 435 def failing_stor(a, b): 436 return defer.succeed(FailingFileWriter(None)) 437 438 # Monkey patch the shell so it returns a file writer that will 439 # fail. 440 self.patch(ftp.FTPAnonymousShell, 'openForWriting', failing_stor) 441 442 def eb(res): 443 self.flushLoggedErrors() 444 res.trap(ftp.CommandFailed) 445 self.assertEquals( 446 res.value.args[0][0], 447 "550 Cannot rmd, ('blah',) is not a directory") 448 d1, d2 = self.client.storeFile('failing_file') 449 d2.addErrback(eb) 450 return defer.gatherResults([d1, d2]) 451 452 426 453 class FTPServerPasvDataConnectionTestCase(FTPServerTestCase): 427 454 def _makeDataConnection(self, ignored=None): 428 455 # Establish a passive data connection (i.e. client connecting to -
twisted/protocols/ftp.py
1112 1112 def ebSent(err): 1113 1113 log.msg("Unexpected error receiving file from client:") 1114 1114 log.err(err) 1115 if err.check(FTPCmdError): 1116 return (err.value.errorCode, err.value.errorMessage) 1115 1117 return (CNX_CLOSED_TXFR_ABORTED,) 1116 1118 1117 1119 def cbConsumer(cons): -
twisted/topfiles/4909.feature
1 twisted.protocols.ftp.FTP.ftp_STOR now catches `FTPCmdError`s raised by 2 the file writer, and returns the error back to the client.
