summaryrefslogtreecommitdiff
path: root/lib/oauthstore.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-13 11:04:41 -0700
committerBrion Vibber <brion@pobox.com>2010-10-13 11:10:04 -0700
commitbca215563ff7aaee5c253b3a55cadc3b02116ef9 (patch)
tree9368ba6a3a4c350180b8dcf798367a1b1f9f13d7 /lib/oauthstore.php
parent2291d68e7019d04ae57f8cb408c42fc775a9a9ff (diff)
Clean up remote avatar temporary files if we fail before saving them into avatars directory (OMB core, OStatus, WikiHowProfile, YammerImport)
Diffstat (limited to 'lib/oauthstore.php')
-rw-r--r--lib/oauthstore.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/oauthstore.php b/lib/oauthstore.php
index 537667678..1c8e72500 100644
--- a/lib/oauthstore.php
+++ b/lib/oauthstore.php
@@ -328,13 +328,18 @@ class StatusNetOAuthDataStore extends OAuthDataStore
function add_avatar($profile, $url)
{
$temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
- copy($url, $temp_filename);
- $imagefile = new ImageFile($profile->id, $temp_filename);
- $filename = Avatar::filename($profile->id,
- image_type_to_extension($imagefile->type),
- null,
- common_timestamp());
- rename($temp_filename, Avatar::path($filename));
+ try {
+ copy($url, $temp_filename);
+ $imagefile = new ImageFile($profile->id, $temp_filename);
+ $filename = Avatar::filename($profile->id,
+ image_type_to_extension($imagefile->type),
+ null,
+ common_timestamp());
+ rename($temp_filename, Avatar::path($filename));
+ } catch (Exception $e) {
+ unlink($temp_filename);
+ throw $e;
+ }
return $profile->setOriginal($filename);
}