mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Fixing starting downloads on startup.
This commit is contained in:
parent
54aa191ff5
commit
08a67eaf74
2 changed files with 14 additions and 7 deletions
14
main.py
14
main.py
|
|
@ -21,7 +21,7 @@ from wrolpi.common import logger, check_media_directory, set_log_level, limit_co
|
|||
create_empty_config_files, TRACE_LEVEL
|
||||
from wrolpi.contexts import attach_shared_contexts, reset_shared_contexts, initialize_configs_contexts
|
||||
from wrolpi.dates import Seconds
|
||||
from wrolpi.downloader import import_downloads_config, download_manager
|
||||
from wrolpi.downloader import import_downloads_config, download_manager, get_download_manager_config
|
||||
from wrolpi.errors import WROLModeEnabled
|
||||
from wrolpi.vars import PROJECT_DIR, DOCKERIZED, INTERNET_SERVER
|
||||
from wrolpi.version import get_version_string
|
||||
|
|
@ -257,9 +257,6 @@ async def start_single_tasks(app: Sanic):
|
|||
# Set all downloads to new.
|
||||
download_manager.retry_downloads()
|
||||
|
||||
if get_wrolpi_config().download_on_startup and download_manager.can_download:
|
||||
await download_manager.enable()
|
||||
|
||||
# Hotspot/throttle are not supported in Docker containers.
|
||||
if not DOCKERIZED:
|
||||
if get_wrolpi_config().hotspot_on_startup:
|
||||
|
|
@ -280,6 +277,15 @@ async def start_single_tasks(app: Sanic):
|
|||
else:
|
||||
logger.info('CPU throttle on startup is disabled')
|
||||
|
||||
if get_wrolpi_config().download_on_startup and not wrol_mode_enabled():
|
||||
# Only start downloading when prerequisites have been met.
|
||||
try:
|
||||
async with flags.have_internet.wait_for(timeout=30):
|
||||
if get_download_manager_config().successful_import:
|
||||
await download_manager.enable()
|
||||
except TimeoutError as e:
|
||||
logger.error('Failed to enable download', exc_info=e)
|
||||
|
||||
logger.debug(f'start_single_tasks done')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from wrolpi.common import ConfigFile, extract_domain, logger, \
|
|||
escape_file_name, get_media_directory, background_task, Base, get_wrolpi_config
|
||||
from wrolpi.dates import Seconds, from_timestamp
|
||||
from wrolpi.db import get_db_curs, get_db_session
|
||||
from wrolpi.downloader import Download
|
||||
from wrolpi.downloader import Download, download_manager
|
||||
from wrolpi.errors import UnknownDirectory
|
||||
from wrolpi.events import Events
|
||||
from wrolpi.files.lib import split_path_stem_and_suffix
|
||||
|
|
@ -297,8 +297,9 @@ class ChannelsConfig(ConfigFile):
|
|||
|
||||
if not channel.source_id and channel.url and flags.have_internet.is_set():
|
||||
# If we can download from a channel, we must have its source_id.
|
||||
logger.info(f'Fetching channel source id for {channel}')
|
||||
background_task(fetch_channel_source_id(channel.id))
|
||||
if download_manager.can_download:
|
||||
logger.info(f'Fetching channel source id for {channel}')
|
||||
background_task(fetch_channel_source_id(channel.id))
|
||||
|
||||
channel_import_logger.debug(f'Updated {repr(channel.name)}'
|
||||
f' url={channel.url}'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue