Browse files

Merge remote-tracking branch 'unRob/master'

  • Loading branch information...
2 parents c3289bc + b5f239f commit 47aac25ed973dda973bdb2bf173bae4ad3d9c0cb @tieleman tieleman committed Jan 7, 2013
Showing with 18 additions and 2 deletions.
  1. +18 −2 lib/job.js
View
20 lib/job.js
@@ -139,8 +139,24 @@ Job.prototype.finalize = function(code, tmpFile) {
if (code == 0) {
fs.rename(tmpFile, job.opts['destination_file'], function (err) {
if (err) {
- util.log(err);
- job.exitHandler(-1, 'ffmpeg finished succesfully, but unable to move file to destination (' + job.opts['destination_file'] + ').');
+ if ( (err.message).match(/EXDEV/) ) {
+ /*
+ EXDEV fix, since util.pump is deprecated, using stream.pipe
+ example from http://stackoverflow.com/questions/11293857/fastest-way-to-copy-file-in-node-js
+ */
+ try {
+ util.log('ffmpeg finished successfully, trying to copy across partitions');
+ fs.createReadStream(tmpFile).pipe(fs.createWriteStream(job.opts['destination_file']));
+ job.exitHandler(code, 'ffmpeg finished succesfully.');
+ } catch (err) {
+ util.log(err);
+ job.exitHandler(-1, 'ffmpeg finished succesfully, but unable to move file to different partition (' + job.opts['destination_file'] + ').');
+ }
+
+ } else {
+ util.log(err);
+ job.exitHandler(-1, 'ffmpeg finished succesfully, but unable to move file to destination (' + job.opts['destination_file'] + ').');
+ }
} else {
job.exitHandler(code, 'ffmpeg finished succesfully.');
}

0 comments on commit 47aac25

Please sign in to comment.