CasparCG / media-scanner

A service used with CasparCG Server software for scanning media located on the server. Queried with query and thumbnail commands through CasparCG Server using AMCP.
https://casparcg.com
GNU Lesser General Public License v3.0
31 stars 33 forks source link

Ignore paths that begin with underscore #73

Closed nytamin closed 9 months ago

nytamin commented 9 months ago

The problem:

I continously get a LOT of error messages in the log, on the form Only reserved document ids may start with underscore..

{"level":50,"time":1705906640456,"pid":25528,"hostname":"NYTAMIN-STATION4","name":"scanner","err":{"type":"PouchError","message":"Only reserved document ids may start with underscore.","st
ack":"Error\n    at new CustomPouchError (C:\\git\\media-scanner\\node_modules\\pouchdb-node\\lib\\index.js:656:21)\n    at createError (C:\\git\\media-scanner\\node_modules\\pouchdb-node\
\lib\\index.js:665:10)\n    at invalidIdError (C:\\git\\media-scanner\\node_modules\\pouchdb-node\\lib\\index.js:794:11)\n    at PouchDB.<anonymous> (C:\\git\\media-scanner\\node_modules\\
pouchdb-node\\lib\\index.js:1754:3)\n    at PouchDB.<anonymous> (C:\\git\\media-scanner\\node_modules\\pouchdb-node\\lib\\index.js:290:21)\n    at PouchDB.<anonymous> (C:\\git\\media-scann
er\\node_modules\\argsarray\\index.js:14:18)\n    at C:\\git\\media-scanner\\node_modules\\pouchdb-node\\lib\\index.js:229:21\n    at new Promise (<anonymous>)\n    at PouchDB.<anonymous>
(C:\\git\\media-scanner\\node_modules\\pouchdb-node\\lib\\index.js:216:19)\n    at PouchDB.put (C:\\git\\media-scanner\\node_modules\\argsarray\\index.js:14:18)","status":400,"name":"bad_r
equest","error":true},"msg":"Only reserved document ids may start with underscore."}

Because I have a folder structure with folders that begin with underscore: /media/_oldClips/clip.mp4

The fix

A simple quick fix: Ignore any ids that begin with underscore, since they cannot be stored in PouchDB anyway, so this should result in no changes in the data written to the DB.

Caveat

This works for me, since I mark folders with underscore in order to ignore them anyway.

But if anyone in the future wishes to scan folders with names that begin with underscore, we could instead change how we generate the ID into a hash (but that's for a later PR).