sergiotapia / torrentinim

A very low memory-footprint, self hosted API-only torrent search engine. Sonarr + Radarr Compatible, native support for Linux, Mac and Windows.
MIT License
782 stars 35 forks source link

issues related to initDatabase #23

Closed srozb closed 2 years ago

srozb commented 3 years ago

Hey, I've cloned master branch and built sources with nimble build (using nim 1.4.8 on MacOS). After successful build I am unable to initialize sqlite database as below:

NUKE_MY_DATABASE=true ./torrentinim

[system] Database nuke requested. Clearing all database tables and data.
/Users/slawek/src-oth/torrentinim/src/torrentinim.nim(23) torrentinim
/Users/slawek/src-oth/torrentinim/src/database.nim(18) initDatabase
/usr/local/Cellar/nim/1.4.8/nim/lib/impure/db_sqlite.nim(227) exec
/usr/local/Cellar/nim/1.4.8/nim/lib/impure/db_sqlite.nim(147) dbError
Error: unhandled exception: near "-": syntax error [DbError]

I believe the problem persist because of lack of quotes around utf-8 here.

srozb commented 3 years ago

Fix merged in #24.

There is however remaining issue related to database not being properly initialized which results in torrents pretending to be inserted into the DB while in fact they aren't.

I think here's a line to blame and this applies to other crawlers too.

According to db_sqlite documentation, proc tryInsertID() will return -1 in case of error and aforementioned line just discarding this fact with no warning/error.

I'd suggest to change application logic (perhaps proc insert_torrent()?) so user is notified of errors related to db operations.

sergiotapia commented 2 years ago

Thanks for the report @srozb! I changed the code so you aren't told an insert happened when it didn't. Much better!