[DB][File] Remove timestamp, add actor_id

This commit is contained in:
Hugo Sales 2020-08-15 05:15:36 +00:00 committed by Hugo Sales
parent 2e9c340684
commit 31ccb2d07b
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 3 additions and 3 deletions

View File

@ -47,10 +47,10 @@ abstract class Utils
$hash = hash_file(File::FILEHASH_ALGO, $sfile->getPathname()); $hash = hash_file(File::FILEHASH_ALGO, $sfile->getPathname());
$file = File::create([ $file = File::create([
'file_hash' => $hash, 'file_hash' => $hash,
'actor_id' => $actor_id,
'mimetype' => $sfile->getMimeType(), 'mimetype' => $sfile->getMimeType(),
'size' => $sfile->getSize(), 'size' => $sfile->getSize(),
'title' => $title ?: _m('Untitled attachment'), 'title' => $title ?: _m('Untitled attachment'),
'timestamp' => $sfile->getMTime(),
'is_local' => $is_local, 'is_local' => $is_local,
]); ]);
$sfile->move($dest_dir, $hash); $sfile->move($dest_dir, $hash);

View File

@ -229,16 +229,16 @@ class File extends Entity
'is_url_protected' => ['type' => 'bool', 'default' => false, 'description' => 'true when URL is private (needs login)'], 'is_url_protected' => ['type' => 'bool', 'default' => false, 'description' => 'true when URL is private (needs login)'],
'url_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of destination URL (url field)'], 'url_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of destination URL (url field)'],
'file_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of the file contents, if the file is stored locally'], 'file_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of the file contents, if the file is stored locally'],
'actor_id' => ['type' => 'int', 'description' => 'If set, used so each actor can have a version of this file (for avatars, for instance)'],
'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'], 'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
'size' => ['type' => 'int', 'description' => 'size of resource when available'], 'size' => ['type' => 'int', 'description' => 'size of resource when available'],
'title' => ['type' => 'text', 'description' => 'title of resource when available'], 'title' => ['type' => 'text', 'description' => 'title of resource when available'],
'timestamp' => ['type' => 'int', 'description' => 'unix timestamp according to http query'],
'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'], 'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],
'primary key' => ['id'], 'primary key' => ['id'],
'unique keys' => [ 'unique keys' => [
'file_file_key' => ['file_hash'], 'file_file_key' => ['file_hash', 'actor_id'],
], ],
'indexes' => [ 'indexes' => [
'file_filehash_idx' => ['file_hash'], 'file_filehash_idx' => ['file_hash'],