try to check whether file exists over and over and over
This commit is contained in:
parent
f2a98e2329
commit
e3c010a870
@ -85,6 +85,13 @@ class File extends Managed_DataObject
|
|||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
function saveNew(array $redir_data, $given_url) {
|
function saveNew(array $redir_data, $given_url) {
|
||||||
|
|
||||||
|
// I don't know why we have to keep doing this but I'm adding this last check to avoid
|
||||||
|
// uniqueness bugs.
|
||||||
|
|
||||||
|
$x = File::staticGet('url', $given_url);
|
||||||
|
|
||||||
|
if (empty($x)) {
|
||||||
$x = new File;
|
$x = new File;
|
||||||
$x->url = $given_url;
|
$x->url = $given_url;
|
||||||
if (!empty($redir_data['protected'])) $x->protected = $redir_data['protected'];
|
if (!empty($redir_data['protected'])) $x->protected = $redir_data['protected'];
|
||||||
@ -93,6 +100,7 @@ class File extends Managed_DataObject
|
|||||||
if (!empty($redir_data['size'])) $x->size = intval($redir_data['size']);
|
if (!empty($redir_data['size'])) $x->size = intval($redir_data['size']);
|
||||||
if (isset($redir_data['time']) && $redir_data['time'] > 0) $x->date = intval($redir_data['time']);
|
if (isset($redir_data['time']) && $redir_data['time'] > 0) $x->date = intval($redir_data['time']);
|
||||||
$file_id = $x->insert();
|
$file_id = $x->insert();
|
||||||
|
}
|
||||||
|
|
||||||
$x->saveOembed($redir_data, $given_url);
|
$x->saveOembed($redir_data, $given_url);
|
||||||
return $x;
|
return $x;
|
||||||
@ -192,7 +200,7 @@ class File extends Managed_DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($x)) {
|
if (empty($x)) {
|
||||||
$x = File::staticGet($file_id);
|
$x = File::staticGet('id', $file_id);
|
||||||
if (empty($x)) {
|
if (empty($x)) {
|
||||||
// @todo FIXME: This could possibly be a clearer message :)
|
// @todo FIXME: This could possibly be a clearer message :)
|
||||||
// TRANS: Server exception thrown when... Robin thinks something is impossible!
|
// TRANS: Server exception thrown when... Robin thinks something is impossible!
|
||||||
|
@ -78,7 +78,13 @@ class BookmarkforurlAction extends Action
|
|||||||
throw new ClientException(_('Invalid URL.'), 400);
|
throw new ClientException(_('Invalid URL.'), 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$f = File::staticGet('url', $this->url);
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
$f = File::processNew($this->url);
|
$f = File::processNew($this->url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// How about now?
|
||||||
|
|
||||||
if (!empty($f)) {
|
if (!empty($f)) {
|
||||||
$this->oembed = File_oembed::staticGet('file_id', $f->id);
|
$this->oembed = File_oembed::staticGet('file_id', $f->id);
|
||||||
|
Loading…
Reference in New Issue
Block a user