From 051389606ea0138ccfe8f79c3b7fd2d75ae121c6 Mon Sep 17 00:00:00 2001 From: shish Date: Mon, 21 Jul 2008 11:13:25 +0000 Subject: [PATCH] make more things use move_upload_to_archive(), and make that function quieter git-svn-id: file:///home/shish/svn/shimmie2/trunk@914 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/handle_flash/main.php | 5 +---- contrib/handle_mp3/main.php | 5 +---- core/util.inc.php | 2 +- ext/handle_pixel/main.php | 5 +---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/contrib/handle_flash/main.php b/contrib/handle_flash/main.php index 07c28228..6aeffdbb 100644 --- a/contrib/handle_flash/main.php +++ b/contrib/handle_flash/main.php @@ -14,10 +14,7 @@ class FlashFileHandler extends Extension { if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { $hash = $event->hash; $ha = substr($hash, 0, 2); - if(!copy($event->tmpname, "images/$ha/$hash")) { - $event->veto("Flash Handler failed to move file from uploads to archive"); - return; - } + if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); $image = $this->create_image_from_data("images/$ha/$hash", $event->metadata); if(is_null($image)) { diff --git a/contrib/handle_mp3/main.php b/contrib/handle_mp3/main.php index e4f4e478..594b798b 100644 --- a/contrib/handle_mp3/main.php +++ b/contrib/handle_mp3/main.php @@ -14,10 +14,7 @@ class MP3FileHandler extends Extension { if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { $hash = $event->hash; $ha = substr($hash, 0, 2); - if(!copy($event->tmpname, "images/$ha/$hash")) { - $event->veto("MP3 Handler failed to move file from uploads to archive"); - return; - } + if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); $image = $this->create_image_from_data("images/$ha/$hash", $event->metadata); if(is_null($image)) { diff --git a/core/util.inc.php b/core/util.inc.php index 4d5e05ff..e4ca8512 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -255,7 +255,7 @@ function get_base_href() { function move_upload_to_archive($event) { $hash = $event->hash; $ha = substr($hash, 0, 2); - if(!copy($event->tmpname, "images/$ha/$hash")) { + if(!@copy($event->tmpname, "images/$ha/$hash")) { $event->veto("Failed to copy file from uploads ({$event->tmpname}) to archive (images/$ha/$hash)"); return false; } diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 83211f4a..29573d69 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -14,10 +14,7 @@ class PixelFileHandler extends Extension { if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { $hash = $event->hash; $ha = substr($hash, 0, 2); - if(!copy($event->tmpname, "images/$ha/$hash")) { - $event->veto("Pixel Handler failed to copy file from uploads ({$event->tmpname}) to archive (images/$ha/$hash)"); - return; - } + if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); $image = $this->create_image_from_data("images/$ha/$hash", $event->metadata); if(is_null($image)) {