Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
fix: file scanning not working when startup, fix #163
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryGeng committed May 31, 2020
1 parent a86a025 commit 8f533cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions media/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ def build_dir_cache(self):
self.dir_lock.acquire()
self.log.info("library: rebuild directory cache")
files = util.get_recursive_file_list_sorted(var.music_folder)

# remove deleted files
results = self.db.query_music(Condition().or_equal('type', 'file'))
for result in results:
if not os.path.exists(os.path.join(var.music_folder, result['path'])):
self.log.debug("library: music file missed: %s, delete from library." % result['path'])
self.db.delete_music(Condition().and_equal('id', result['id']))

for file in files:
results = self.db.query_music(Condition().and_equal('path', file))
if not results:
Expand Down
4 changes: 2 additions & 2 deletions mumbleBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def __init__(self, args):
self.channel = var.config.get("server", "channel", fallback=None)

var.user = args.user
var.music_folder = util.solve_filepath(var.config.get('bot', 'music_folder'))
var.tmp_folder = util.solve_filepath(var.config.get('bot', 'tmp_folder'))
var.is_proxified = var.config.getboolean(
"webinterface", "is_web_proxified")
self.exit = False
Expand Down Expand Up @@ -768,6 +766,8 @@ def start_web_interface(addr, port):

DatabaseMigration(var.db, var.music_db).migrate()

var.music_folder = util.solve_filepath(var.config.get('bot', 'music_folder'))
var.tmp_folder = util.solve_filepath(var.config.get('bot', 'tmp_folder'))
var.cache = MusicCache(var.music_db)

if var.config.get("bot", "refresh_cache_on_startup", fallback=True):
Expand Down

0 comments on commit 8f533cd

Please sign in to comment.