From 8d2ca716df4ecfc6b55ea614a952641a8274540f Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sat, 20 Aug 2011 11:07:30 +0100 Subject: [PATCH] Updated worker to copy rather than move output to final location This causes ACLs to be inherited from the destination, rather than preserving permissions from the temporary build location on the local machine. --- source/lib/Net/Gearman/Job/HandBrake.class.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/source/lib/Net/Gearman/Job/HandBrake.class.php b/source/lib/Net/Gearman/Job/HandBrake.class.php index 81d1b30..5ce4830 100644 --- a/source/lib/Net/Gearman/Job/HandBrake.class.php +++ b/source/lib/Net/Gearman/Job/HandBrake.class.php @@ -66,19 +66,29 @@ class Net_Gearman_Job_HandBrake extends Net_Gearman_Job_Common implements Rippin if ($return_val) { // Remove any temporary output files if (file_exists($args['temp_output_filename'])) { - unlink($args['temp_output_filename']); + $result = unlink($args['temp_output_filename']); + if ($result) { + RippingCluster_WorkerLogEntry::warning($log, $this->job->id(), "Failed to remove temporary output file, still exists at '{$args['temp_output_filename']}'."); + } } $this->fail($return_val); } else { - // Move the temporary output file to the desired destination - $move = rename($args['temp_output_filename'], $args['rip_options']['output_filename']); + // Copy the temporary output file to the desired destination + $move = copy($args['temp_output_filename'], $args['rip_options']['output_filename']); if ($move) { + // Remove the temporary output file + $result = unlink($args['temp_output_filename']); + if ($result) { + RippingCluster_WorkerLogEntry::warning($log, $this->job->id(), "Failed to remove temporary output file, still exists at '{$args['temp_output_filename']}'."); + } + + //Report success $this->job->updateStatus(RippingCluster_JobStatus::COMPLETE); $this->complete( array( 'id' => $this->job->id() )); } else { - RippingCluster_WorkerLogEntry::error($log, $this->job->id(), "Failed to move temporary output file to proper destination. File retained as '{$args['temp_output_filename']}'."); + RippingCluster_WorkerLogEntry::error($log, $this->job->id(), "Failed to copy temporary output file to proper destination. File retained as '{$args['temp_output_filename']}'."); $this->job->updateStatus(RippingCluster_JobStatus::FAILED); $this->fail('-1'); }