Don't batch download when offline mode

This commit is contained in:
Sumner Evans
2020-05-29 19:21:35 -06:00
parent 22bb98b68e
commit cd676cc790
2 changed files with 15 additions and 7 deletions

View File

@@ -866,7 +866,11 @@ class AdapterManager:
cancelled = False
def do_download_song(song_id: str):
if AdapterManager.is_shutting_down or cancelled:
if (
AdapterManager.is_shutting_down
or AdapterManager._offline_mode
or cancelled
):
return
assert AdapterManager._instance
@@ -915,16 +919,16 @@ class AdapterManager:
def do_batch_download_songs():
sleep(delay)
for song_id in song_ids:
if cancelled:
if (
AdapterManager.is_shutting_down
or AdapterManager._offline_mode
or cancelled
):
return
# Only allow a certain number of songs to be downloaded
# simultaneously.
AdapterManager._instance.download_limiter_semaphore.acquire()
# Prevents further songs from being downloaded.
if AdapterManager.is_shutting_down:
break
result = Result(do_download_song, song_id, is_download=True)
if one_at_a_time:

View File

@@ -1093,7 +1093,11 @@ class SublimeMusicApp(Gtk.Application):
self.update_window()
if (
self.app_config.allow_song_downloads
# This only makes sense if the adapter is networked.
AdapterManager.ground_truth_adapter_is_networked()
# Don't download in offline mode.
and not self.app_config.offline_mode
and self.app_config.allow_song_downloads
and self.app_config.download_on_stream
and AdapterManager.can_batch_download_songs()
):