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)) {