Skip to content

Commit b72f1c8

Browse files
committed
Rewrite code to avoid deprecated ensure statement
See xp-framework/core#111
1 parent 672279b commit b72f1c8

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ FTP protocol support for the XP Framework ChangeLog
33

44
## ?.?.? / ????-??-??
55

6+
## 6.2.1 / 2015-12-20
7+
8+
* Rewrote code to avoid deprecated ensure statement - @thekid
9+
610
## 6.2.0 / 2015-12-14
711

812
* **Heads up**: Changed minimum XP version to XP 6.5.0, and with it the

src/main/php/peer/ftp/server/FtpProtocol.class.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,12 @@ public function onRetr($socket, $params) {
662662
if (!$dataSocket->write($buf)) break;
663663
}
664664
$entry->close();
665+
$dataSocket->close();
666+
$this->answer($socket, 226, 'Transfer complete');
665667
} catch (\lang\XPException $e) {
666668
$this->answer($socket, 550, $params.': '.$e->getMessage());
667-
} ensure($e); {
668669
$dataSocket->close();
669-
if ($e) return;
670670
}
671-
$this->answer($socket, 226, 'Transfer complete');
672671
}
673672

674673
/**
@@ -713,20 +712,20 @@ public function onStor($socket, $params) {
713712
$entry->write($buf);
714713
}
715714
$entry->close();
715+
$dataSocket->close();
716+
717+
// Post check interception
718+
if (!$this->checkInterceptors($socket, $entry, 'onStored')) {
719+
$entry->delete();
720+
return;
721+
}
722+
723+
$this->answer($socket, 226, 'Transfer complete');
716724
} catch (\lang\XPException $e) {
717725
$this->answer($socket, 550, $params.': '.$e->getMessage());
718-
} ensure($e); {
719726
$dataSocket->close();
720-
if ($e) return;
721-
}
722-
723-
// Post check interception
724-
if (!$this->checkInterceptors($socket, $entry, 'onStored')) {
725-
$entry->delete();
726727
return;
727728
}
728-
729-
$this->answer($socket, 226, 'Transfer complete');
730729
}
731730

732731
/**

0 commit comments

Comments
 (0)