diff --git a/ChangeLog.md b/ChangeLog.md index 6910744c..134f76ee 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,10 @@ FTP protocol support for the XP Framework ChangeLog ## ?.?.? / ????-??-?? +## 6.2.1 / 2015-12-20 + +* Rewrote code to avoid deprecated ensure statement - @thekid + ## 6.2.0 / 2015-12-14 * **Heads up**: Changed minimum XP version to XP 6.5.0, and with it the diff --git a/src/main/php/peer/ftp/server/FtpProtocol.class.php b/src/main/php/peer/ftp/server/FtpProtocol.class.php index c4620b01..0e8962dd 100644 --- a/src/main/php/peer/ftp/server/FtpProtocol.class.php +++ b/src/main/php/peer/ftp/server/FtpProtocol.class.php @@ -662,13 +662,12 @@ public function onRetr($socket, $params) { if (!$dataSocket->write($buf)) break; } $entry->close(); + $dataSocket->close(); + $this->answer($socket, 226, 'Transfer complete'); } catch (\lang\XPException $e) { $this->answer($socket, 550, $params.': '.$e->getMessage()); - } ensure($e); { $dataSocket->close(); - if ($e) return; } - $this->answer($socket, 226, 'Transfer complete'); } /** @@ -713,20 +712,20 @@ public function onStor($socket, $params) { $entry->write($buf); } $entry->close(); + $dataSocket->close(); + + // Post check interception + if (!$this->checkInterceptors($socket, $entry, 'onStored')) { + $entry->delete(); + return; + } + + $this->answer($socket, 226, 'Transfer complete'); } catch (\lang\XPException $e) { $this->answer($socket, 550, $params.': '.$e->getMessage()); - } ensure($e); { $dataSocket->close(); - if ($e) return; - } - - // Post check interception - if (!$this->checkInterceptors($socket, $entry, 'onStored')) { - $entry->delete(); return; } - - $this->answer($socket, 226, 'Transfer complete'); } /**