NotJoeMartinez / yt-fts

YouTube Full Text Search - Search all of a YouTube channel from the command line
The Unlicense
1.61k stars 81 forks source link

Fix `sqlite3.OperationalError: database is locked` on delete #120

Closed NotJoeMartinez closed 10 months ago

NotJoeMartinez commented 10 months ago

Database delete fails locks on delete, how did this not show up on testing?

 yt-fts delete -c 10
Deleting channel Ben Eater: https://www.youtube.com/channel/UCS0N5baNlQWJCUrhCEo8WlA/videos
Are you sure you want to delete this channel and all its data?
y/n: y
Traceback (most recent call last):
  File "/usr/local/bin/yt-fts", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/yt_fts/yt_fts.py", line 144, in delete
    delete_channel(channel_id)
  File "/usr/local/lib/python3.11/site-packages/yt_fts/db_utils.py", line 171, in delete_channel
    if check_ss_enabled(channel_id):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/yt_fts/utils.py", line 107, in check_ss_enabled
    cur.execute("""
    ^^^^^^^^^^^^^^^
sqlite3.OperationalError: database is locked
NotJoeMartinez commented 10 months ago

fixed with " Db lock error on delete #121 "