Skip to content

Commit

Permalink
Rewrite code to avoid deprecated ensure statement
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Dec 20, 2015
1 parent 672279b commit b72f1c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 11 additions & 12 deletions src/main/php/peer/ftp/server/FtpProtocol.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -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');
}

/**
Expand Down

0 comments on commit b72f1c8

Please sign in to comment.