jansmolders86 / mediacenterjs

A HTML/CSS/Javascript (NodeJS) based Media center
http://mediacenterjs.com
1.29k stars 245 forks source link

Doesn't handle paths with spaces well on linux #91

Closed gkatsev closed 10 years ago

gkatsev commented 10 years ago

I have all my media in the following paths:

/media/Media A/Videos/
/media/Media A/Music/
/media/Media A/TV Shows/

Unfortunately, when it tries to scan the folder, it fails because it's trying to scan /media/Media.

gkatsev commented 10 years ago

Specifically, I receive the following errors:

Database error: Error: near line 13: no such table: movies

module.js:340

    throw err;
          ^

Error: Cannot find module '/media/Media'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

Metadata fetching for movie complete...
Child process exited for:  movie
Metadata fetcher error:  { [Error: Command failed: 
module.js:340
    throw err;
          ^
Error: Cannot find module '/media/Media'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3
] killed: false, code: 8, signal: null }
Database error: Error: near line 15: no such table: movies

Could not index any movies, please check given movie collection path
gkatsev commented 10 years ago

Changing console.error to throw new Error, I was able to find out specifically where the db error is occuring:

/media/Media A/Documents/projects/mediacenterjs/apps/movies/movie-functions.js:18
db.on('error', function (err) { throw new Error('Database error: ' + err) });
                                      ^
Error: Database error: Error: near line 1: no such table: movies

    at EventEmitter.exports.loadItems.db.query.original_name (/media/Media A/Documents/projects/mediacenterjs/apps/movies/movie-functions.js:18:39)
    at EventEmitter.emit (events.js:95:17)
    at Socket.onerror (/media/Media A/Documents/projects/mediacenterjs/node_modules/dblite/build/dblite.node.js:228:12)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
gkatsev commented 10 years ago

After more investigation, it's because of this line. There we try to exec the movie metadata js in a child but the path has a space in it. The beginning of a fix is to escape the spaces before calling exec.

jansmolders86 commented 10 years ago

Hej Gary,

Thanks for reporting this issue and investigating so thoroughly! I really appreciate it. I will definitely get going on the fix asap. I'll keep you posted of course.

Thanks again!

gkatsev commented 10 years ago

I think I have a fix, also!