nisaacson / pdf-extract

Node PDF Extract
MIT License
383 stars 76 forks source link

The tests are failing in the ubuntu 13.04 #3

Closed Lujaw closed 10 years ago

Lujaw commented 10 years ago

7 tests are failing when running the npm test. Most of them are due to "Error: timeout of 100000ms exceeded" Have tried increasing the timeout value but that doesn't help too ..

nisaacson commented 10 years ago

Do you have all the required dependencies installed?

alexscheelmeyer commented 10 years ago

This sounds like the same issue I have experienced on OS X. I got the same error on timeout.

I have modified the split.js file from:

  walker.on('file', function(root, stat, next) {
    if (stat.name.match(/\.pdf$/i)) {
      var file_path = path.join(directory_path, stat.name);
      file_paths.push({file_path: file_path, file_name: stat.name});
      next();
    }
  });

to

  walker.on('file', function(root, stat, next) {
    if (stat.name.match(/\.pdf$/i)) {
      var file_path = path.join(directory_path, stat.name);
      file_paths.push({file_path: file_path, file_name: stat.name});
    }
    next();
  });

and now the tests pass. The trouble seems to be that doc_data_path is set to current folder while the file is actually placed in the temporary output folder by pdftk. This means that remove_doc_data fails to remove the file and in turn that the walker code chokes on the file as it only expects pdf-files.

nisaacson commented 10 years ago

good catch @alexscheelmeyer. Care to open a pull request with your fix?

nisaacson commented 10 years ago

Should be fixed in latest version 1.0.6 published to npm. Please send feedback if other issues occur