[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:
@@ -189,14 +189,12 @@ class EmbedPlugin extends Plugin
|
||||
foreach (['xml', 'json'] as $format) {
|
||||
$action->element(
|
||||
'link',
|
||||
['rel' =>'alternate',
|
||||
'type' => "application/{$format}+oembed",
|
||||
'href' => common_local_url(
|
||||
'oembed',
|
||||
[],
|
||||
['format' => $format, 'url' => $url]
|
||||
),
|
||||
'title' => 'oEmbed']
|
||||
[
|
||||
'rel' =>'alternate',
|
||||
'type' => "application/{$format}+oembed",
|
||||
'href' => common_local_url('oembed', [], ['format' => $format, 'url' => $url]),
|
||||
'title' => 'oEmbed'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ class OEmbedAction extends Action
|
||||
}
|
||||
try {
|
||||
$thumb = $attachment->getThumbnail();
|
||||
$thumb_url = File_thumbnail::url($thumb->filename);
|
||||
$thumb_url = $thumb->getUrl();
|
||||
$oembed['thumbnail_url'] = $thumb_url;
|
||||
break; // only first one
|
||||
} catch (UseFileAsThumbnailException $e) {
|
||||
|
@@ -917,7 +917,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||
}
|
||||
|
||||
// ImageFile throws exception if something goes wrong, which we'll let go on its merry way
|
||||
$imagefile = ImageFile::fromURL($url);
|
||||
$imagefile = ImageFile::fromUrl($url);
|
||||
|
||||
$self = $this->localProfile();
|
||||
|
||||
|
@@ -138,6 +138,7 @@ class StoreRemoteMediaPlugin extends Plugin
|
||||
try {
|
||||
// Exception will be thrown before $file is set to anything, so old $file value will be kept
|
||||
$file = File::getByHash($filehash);
|
||||
$file->fetch();
|
||||
|
||||
//FIXME: Add some code so we don't have to store duplicate File rows for same hash files.
|
||||
} catch (NoResultException $e) {
|
||||
|
Reference in New Issue
Block a user