forked from GNUsocial/gnu-social
[Media] Fix issues with database file storage
Fixed file quota as well. There can be more than one file for the same filehash IF the url are different. Possible states: - A file with no url and with filename is a local file. - A file with an url but no filename is a remote file that wasn't fetched, not even the thumbnail. - A file with an url and filename is a fetched remote file (maybe just a thumbnail of it). - A file with no filename nor url is a redirect. Routes: Given these states, updated routes so that an attachment can only be retrieved by id and a file by filehash. Major API changes: File::getByHash now returns a yield of files Major UI changes: - Now remote non stored files are presented. - /view became preferred - Redirects to remote originals are preferred. Many other minor bug fixes...
This commit is contained in:
@@ -223,16 +223,18 @@ class Router
|
||||
['q' => '.+']);
|
||||
$m->connect('search/notice/rss', ['action' => 'noticesearchrss']);
|
||||
|
||||
foreach (['' => 'attachment',
|
||||
'/view' => 'attachment_view',
|
||||
'/download' => 'attachment_download',
|
||||
// Attachment page for file
|
||||
$m->connect("attachment/:attachment",
|
||||
['action' => 'attachment'],
|
||||
['attachment' => '[0-9]+']);
|
||||
|
||||
// Retrieve local file
|
||||
foreach (['/view' => 'attachment_view',
|
||||
'/download' => 'attachment_download',
|
||||
'/thumbnail' => 'attachment_thumbnail'] as $postfix => $action) {
|
||||
foreach (['filehash' => '[A-Za-z0-9._-]{64}',
|
||||
'attachment' => '[0-9]+'] as $type => $match) {
|
||||
$m->connect("attachment/:{$type}{$postfix}",
|
||||
$m->connect("attachment/:filehash{$postfix}",
|
||||
['action' => $action],
|
||||
[$type => $match]);
|
||||
}
|
||||
['filehash' => '[A-Za-z0-9._-]{64}']);
|
||||
}
|
||||
|
||||
$m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
|
||||
|
Reference in New Issue
Block a user