mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 13:49:57 -05:00
Not sending refresh events for channel downloads.
This commit is contained in:
parent
6122ebb68c
commit
9dfaabdb9b
5 changed files with 15 additions and 9 deletions
|
|
@ -255,7 +255,8 @@ def test_channel_empty_url_doesnt_conflict(test_client, test_session, test_direc
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download_channel_no_refresh(test_session, download_channel, video_download_manager, video_factory):
|
||||
async def test_channel_download_requires_refresh(test_session, download_channel, video_download_manager, video_factory,
|
||||
events_history):
|
||||
"""A Channel cannot be downloaded until it has been refreshed.
|
||||
|
||||
Videos already downloaded are not downloaded again."""
|
||||
|
|
@ -301,6 +302,9 @@ async def test_download_channel_no_refresh(test_session, download_channel, video
|
|||
# Only the missing video was downloaded.
|
||||
assert downloaded_urls == ['https://example.com/2']
|
||||
|
||||
# Should not send refresh events because downloads are automated.
|
||||
assert events_history == []
|
||||
|
||||
|
||||
def test_channel_post_directory(test_session, test_client, test_directory):
|
||||
"""A Channel can be created with or without an existing directory."""
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class ChannelDownloader(Downloader, ABC):
|
|||
channel = get_channel(session, channel_id=channel_id, return_dict=False)
|
||||
if not channel.videos or not channel.refreshed:
|
||||
logger.warning(f'Refreshing videos in {channel.directory} because {channel} has no video records!')
|
||||
await channel.refresh_files()
|
||||
await channel.refresh_files(send_events=False)
|
||||
session.commit() # Commit the refresh.
|
||||
session.refresh(channel)
|
||||
|
||||
|
|
|
|||
|
|
@ -479,14 +479,14 @@ class Channel(ModelHelper, Base):
|
|||
)
|
||||
return statistics
|
||||
|
||||
async def refresh_files(self):
|
||||
async def refresh_files(self, send_events: bool = True):
|
||||
"""Refresh all files within this Channel's directory. Mark this channel as refreshed."""
|
||||
logger.debug('Channel.refresh_files refresh_files')
|
||||
# Get this Channel's ID for later. Refresh may take a long time.
|
||||
self_id = self.id
|
||||
|
||||
# Refresh all files within this channel's directory first.
|
||||
await refresh_directory_files_recursively(self.directory)
|
||||
await refresh_directory_files_recursively(self.directory, send_events=send_events)
|
||||
|
||||
# Apply any info_json (discover censored videos, etc.) second.
|
||||
from modules.videos.common import apply_info_json
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue