Page MenuHomePhorge

No OneTemporary

diff --git a/src/future/postmark/PhutilPostmarkFuture.php b/src/future/postmark/PhutilPostmarkFuture.php
index 23c21f47..fcf6e9d7 100644
--- a/src/future/postmark/PhutilPostmarkFuture.php
+++ b/src/future/postmark/PhutilPostmarkFuture.php
@@ -1,100 +1,101 @@
<?php
final class PhutilPostmarkFuture extends FutureProxy {
private $future;
+ private $clientID;
private $accessToken;
private $method;
private $parameters;
private $timeout;
public function __construct() {
parent::__construct(null);
}
public function setAccessToken($token) {
$this->accessToken = $token;
return $this;
}
public function setClientID($client_id) {
$this->clientID = $client_id;
return $this;
}
public function setMethod($method, array $parameters) {
$this->method = $method;
$this->parameters = $parameters;
return $this;
}
public function setTimeout($timeout) {
$this->timeout = $timeout;
return $this;
}
public function getTimeout() {
return $this->timeout;
}
protected function getProxiedFuture() {
if (!$this->future) {
if ($this->accessToken === null) {
throw new PhutilInvalidStateException('setAccessToken');
}
if ($this->method === null || $this->parameters === null) {
throw new PhutilInvalidStateException('setMethod');
}
$uri = id(new PhutilURI('https://api.postmarkapp.com/'))
->setPath('/'.$this->method);
$request_body = phutil_json_encode($this->parameters);
$future = id(new HTTPSFuture($uri))
->setData($request_body)
->setMethod('POST')
->addHeader('X-Postmark-Server-Token', $this->accessToken)
->addHeader('Accept', 'application/json')
->addHeader('Content-Type', 'application/json');
$timeout = $this->getTimeout();
if ($timeout) {
$future->setTimeout($timeout);
}
$this->future = $future;
}
return $this->future;
}
protected function didReceiveResult($result) {
list($status, $body, $headers) = $result;
if ($status->isError()) {
throw $status;
}
try {
$data = phutil_json_decode($body);
} catch (PhutilJSONParserException $ex) {
throw new PhutilProxyException(
pht('Expected JSON response from Postmark.'),
$ex);
}
if (idx($data, 'ErrorCode')) {
$error = $data['ErrorCode'];
throw new Exception(
pht(
'Received error from Postmark: (%s) %s',
$error,
idx($data, 'Message')));
}
return $data;
}
}
diff --git a/src/workingcopy/ArcanistWorkingCopyPath.php b/src/workingcopy/ArcanistWorkingCopyPath.php
index 217d5932..80b03bce 100644
--- a/src/workingcopy/ArcanistWorkingCopyPath.php
+++ b/src/workingcopy/ArcanistWorkingCopyPath.php
@@ -1,129 +1,130 @@
<?php
final class ArcanistWorkingCopyPath
extends Phobject {
private $path;
private $mode;
private $data;
private $binary;
+ private $mimeType;
private $dataAsLines;
private $charMap;
private $lineMap;
public function setPath($path) {
$this->path = $path;
return $this;
}
public function getPath() {
return $this->path;
}
public function setData($data) {
$this->data = $data;
return $this;
}
public function getData() {
if ($this->data === null) {
throw new Exception(
pht(
'No data provided for path "%s".',
$this->getPath()));
}
return $this->data;
}
public function getDataAsLines() {
if ($this->dataAsLines === null) {
$lines = phutil_split_lines($this->getData());
$this->dataAsLines = $lines;
}
return $this->dataAsLines;
}
public function setMode($mode) {
$this->mode = $mode;
return $this;
}
public function getMode() {
if ($this->mode === null) {
throw new Exception(
pht(
'No mode provided for path "%s".',
$this->getPath()));
}
return $this->mode;
}
public function isExecutable() {
$mode = $this->getMode();
return (bool)($mode & 0111);
}
public function isBinary() {
if ($this->binary === null) {
$data = $this->getData();
$is_binary = ArcanistDiffUtils::isHeuristicBinaryFile($data);
$this->binary = $is_binary;
}
return $this->binary;
}
public function getMimeType() {
if ($this->mimeType === null) {
// TOOLSETS: This is not terribly efficient on real repositories since
// it re-writes files which are often already on disk, but is good for
// unit tests.
$tmp = new TempFile();
Filesystem::writeFile($tmp, $this->getData());
$mime = Filesystem::getMimeType($tmp);
$this->mimeType = $mime;
}
return $this->mimeType;
}
public function getBasename() {
return basename($this->getPath());
}
public function getLineAndCharFromOffset($offset) {
if ($this->charMap === null) {
$char_map = array();
$line_map = array();
$lines = $this->getDataAsLines();
$line_number = 0;
$line_start = 0;
foreach ($lines as $line) {
$len = strlen($line);
$line_map[] = $line_start;
$line_start += $len;
for ($ii = 0; $ii < $len; $ii++) {
$char_map[] = $line_number;
}
$line_number++;
}
$this->charMap = $char_map;
$this->lineMap = $line_map;
}
$line = $this->charMap[$offset];
$char = $offset - $this->lineMap[$line];
return array($line, $char);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Jan 19 2025, 21:46 (6 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129080
Default Alt Text
(5 KB)

Event Timeline