Skip to content
Snippets Groups Projects
Commit 906a6b18 authored by Jared Hancock's avatar Jared Hancock
Browse files

Write new signature on file data loading

parent 7c4abfa3
No related branches found
No related tags found
No related merge requests found
...@@ -104,18 +104,22 @@ class FileManager extends Module { ...@@ -104,18 +104,22 @@ class FileManager extends Module {
} }
catch (Exception $e) {} catch (Exception $e) {}
if ($options['backend']) if ($options['to'])
$bk = FileStorageBackend::lookup($options['backend'], $f); $bk = FileStorageBackend::lookup($options['to'], $f);
else else
// Use the system default // Use the system default
$bk = AttachmentFile::getBackendForFile($f); $bk = AttachmentFile::getBackendForFile($f);
$type = false; $type = false;
$signature = '';
$finfo = new finfo(FILEINFO_MIME_TYPE); $finfo = new finfo(FILEINFO_MIME_TYPE);
if ($options['file'] && $options['file'] != '-') { if ($options['file'] && $options['file'] != '-') {
if (!file_exists($options['file']))
$this->fail($options['file'].': Cannot open file');
if (!$bk->upload($options['file'])) if (!$bk->upload($options['file']))
$this->fail('Unable to upload file contents to backend'); $this->fail('Unable to upload file contents to backend');
$type = $finfo->file($options['file']); $type = $finfo->file($options['file']);
list(, $signature) = AttachmentFile::_getKeyAndHash($options['file'], true);
} }
else { else {
$stream = fopen('php://stdin', 'rb'); $stream = fopen('php://stdin', 'rb');
...@@ -133,6 +137,7 @@ class FileManager extends Module { ...@@ -133,6 +137,7 @@ class FileManager extends Module {
$sql = 'UPDATE '.FILE_TABLE.' SET bk='.db_input($bk->getBkChar()) $sql = 'UPDATE '.FILE_TABLE.' SET bk='.db_input($bk->getBkChar())
.', created=CURRENT_TIMESTAMP' .', created=CURRENT_TIMESTAMP'
.', type='.db_input($type) .', type='.db_input($type)
.', signature='.db_input($signature)
.' WHERE id='.db_input($f->getId()); .' WHERE id='.db_input($f->getId());
if (!db_query($sql) || db_affected_rows()!=1) if (!db_query($sql) || db_affected_rows()!=1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment