mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-04 19:30:13 +00:00
add rescan lock
This commit is contained in:
parent
40c7a6a3f7
commit
4136a2a4f2
@ -38,7 +38,13 @@ def make_folders():
|
|||||||
|
|
||||||
def release_lock():
|
def release_lock():
|
||||||
"""make sure there are no leftover locks set in redis on container start"""
|
"""make sure there are no leftover locks set in redis on container start"""
|
||||||
all_locks = ["manual_import", "downloading", "dl_queue", "dl_queue_id"]
|
all_locks = [
|
||||||
|
"manual_import",
|
||||||
|
"downloading",
|
||||||
|
"dl_queue",
|
||||||
|
"dl_queue_id",
|
||||||
|
"rescan",
|
||||||
|
]
|
||||||
for lock in all_locks:
|
for lock in all_locks:
|
||||||
response = RedisArchivist().del_message(lock)
|
response = RedisArchivist().del_message(lock)
|
||||||
if response:
|
if response:
|
||||||
|
@ -45,17 +45,28 @@ def update_subscribed():
|
|||||||
"title": "Start rescanning channels and playlists.",
|
"title": "Start rescanning channels and playlists.",
|
||||||
}
|
}
|
||||||
RedisArchivist().set_message("progress:download", message)
|
RedisArchivist().set_message("progress:download", message)
|
||||||
|
|
||||||
|
have_lock = False
|
||||||
|
my_lock = RedisArchivist().get_lock("rescan")
|
||||||
|
|
||||||
|
try:
|
||||||
|
have_lock = my_lock.acquire(blocking=False)
|
||||||
|
if have_lock:
|
||||||
channel_handler = ChannelSubscription()
|
channel_handler = ChannelSubscription()
|
||||||
missing_from_channels = channel_handler.find_missing()
|
missing_from_channels = channel_handler.find_missing()
|
||||||
playlist_handler = PlaylistSubscription()
|
playlist_handler = PlaylistSubscription()
|
||||||
missing_from_playlists = playlist_handler.find_missing()
|
missing_from_playlists = playlist_handler.find_missing()
|
||||||
missing_videos = missing_from_channels + missing_from_playlists
|
missing = missing_from_channels + missing_from_playlists
|
||||||
if missing_videos:
|
if missing:
|
||||||
pending_handler = PendingList()
|
pending_handler = PendingList()
|
||||||
all_videos_added = pending_handler.add_to_pending(missing_videos)
|
all_videos_added = pending_handler.add_to_pending(missing)
|
||||||
ThumbManager().download_vid(all_videos_added)
|
ThumbManager().download_vid(all_videos_added)
|
||||||
# check if reindex is needed
|
else:
|
||||||
check_reindex.delay()
|
print("Did not acquire rescan lock.")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
if have_lock:
|
||||||
|
my_lock.release()
|
||||||
|
|
||||||
|
|
||||||
@shared_task(name="download_pending")
|
@shared_task(name="download_pending")
|
||||||
|
Loading…
Reference in New Issue
Block a user