Changeset View
Changeset View
Standalone View
Standalone View
src/upload/ArcanistFileDataRef.php
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | if ($have_path) { | ||||
Filesystem::assertReadable($path); | Filesystem::assertReadable($path); | ||||
} catch (FilesystemException $ex) { | } catch (FilesystemException $ex) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Unable to upload file: path "%s" is not readable.', | 'Unable to upload file: path "%s" is not readable.', | ||||
$path)); | $path)); | ||||
} | } | ||||
$hash = @sha1_file($path); | |||||
if ($hash === false) { | |||||
throw new Exception( | |||||
pht( | |||||
'Unable to upload file: failed to calculate file data hash for '. | |||||
'path "%s".', | |||||
$path)); | |||||
} | |||||
$size = @filesize($path); | $size = @filesize($path); | ||||
if ($size === false) { | if ($size === false) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Unable to upload file: failed to determine filesize of '. | 'Unable to upload file: failed to determine filesize of '. | ||||
'path "%s".', | 'path "%s".', | ||||
$path)); | $path)); | ||||
} | } | ||||
$this->hash = $hash; | $this->hash = $this->newFileHash($path); | ||||
$this->size = $size; | $this->size = $size; | ||||
} else { | } else { | ||||
$data = $this->data; | $data = $this->data; | ||||
$this->hash = sha1($data); | $this->hash = $this->newDataHash($data); | ||||
$this->size = strlen($data); | $this->size = strlen($data); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* @task uploader | * @task uploader | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | if ($data === false) { | ||||
$len, | $len, | ||||
$start, | $start, | ||||
$path)); | $path)); | ||||
} | } | ||||
return $data; | return $data; | ||||
} | } | ||||
private function newFileHash($path) { | |||||
return null; | |||||
} | |||||
private function newDataHash($data) { | |||||
return null; | |||||
} | |||||
} | } |