1 Commits

Author SHA1 Message Date
8d2ca716df 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.
2011-08-20 11:07:30 +01:00

View File

@@ -66,19 +66,29 @@ class Net_Gearman_Job_HandBrake extends Net_Gearman_Job_Common implements Rippin
if ($return_val) { if ($return_val) {
// Remove any temporary output files // Remove any temporary output files
if (file_exists($args['temp_output_filename'])) { 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); $this->fail($return_val);
} else { } else {
// Move the temporary output file to the desired destination // Copy the temporary output file to the desired destination
$move = rename($args['temp_output_filename'], $args['rip_options']['output_filename']); $move = copy($args['temp_output_filename'], $args['rip_options']['output_filename']);
if ($move) { 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->job->updateStatus(RippingCluster_JobStatus::COMPLETE);
$this->complete( array( $this->complete( array(
'id' => $this->job->id() 'id' => $this->job->id()
)); ));
} else { } 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->job->updateStatus(RippingCluster_JobStatus::FAILED);
$this->fail('-1'); $this->fail('-1');
} }