ContentMine / getpapers

Get metadata, fulltexts or fulltext URLs of papers matching a search query
MIT License
197 stars 37 forks source link

Error: EACCES: permission denied (cannot mkdir for results) #174

Open petermr opened 5 years ago

petermr commented 5 years ago
getpapers -q "((Ocimum sanctum) OR (Ocimum) OR (Ocimum tenuiflorum) OR (thulasi) OR (tulasi) OR (tulsi) OR (holy basil))" -x -p -a -o Ocimumproject17feb
info: Searching using eupmc API
info: Found 4895 results
warn: This version of getpapers wasn't built with this version of the EuPMC api in mind
warn: getpapers EuPMCVersion: 5.3.2 vs. 6.0.3 reported by api
Retrieving results [==============================] 100% (eta 0.0s)
info: Done collecting results
info: Duplicate records found: 4843 unique results identified
info: Saving result metadata
info: Full EUPMC result metadata written to eupmc_results.json
Potentially unhandled rejection [1] Error: EACCES: permission denied, mkdir '/s0074-02762005000100011'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:916:18)
    at Function.sync (/usr/local/n/versions/node/6.2.1/lib/node_modules/getpapers/node_modules/mkdirp/index.js:71:13)
    at EuPmc.writeRecord (/usr/local/n/versions/node/6.2.1/lib/node_modules/getpapers/lib/eupmc.js:588:10)
    at /usr/local/n/versions/node/6.2.1/lib/node_modules/getpapers/lib/eupmc.js:226:11
    at Array.forEach (native)
    at EuPmc.handleSearchResults (/usr/local/n/versions/node/6.2.1/lib/node_modules/getpapers/lib/eupmc.js:225:20)
    at EuPmc.completeCallback (/usr/local/n/versions/node/6.2.1/lib/node_modules/getpapers/lib/eupmc.js:167:11)
    at /usr/local/n/versions/node/6.2.1/lib/node_modules/getpapers/lib/eupmc.js:97:7
    at Parser.<anonymous> (/usr/local/n/versions/node/6.2.1/lib/node_modules/getpapers/node_modules/xml2js/lib/parser.js:303:18)

The code appears to be:

EuPmc.prototype.writeRecord = function (record, eupmc) {
  var json = JSON.stringify(record, null, 2)
  var id = eupmc.getIdentifier(record).id
  mkdirp.sync(id)
  fs.writeFileSync(id + '/eupmc_result.json', json)
}

maybe the id is corrupted or has unusual syntax.

Potential fix is to trap and skip?