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