Not sending refresh events for channel downloads.

This commit is contained in:
Roland 2022-12-29 09:36:24 -07:00
parent 6122ebb68c
commit 9dfaabdb9b
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
5 changed files with 15 additions and 9 deletions

View file

@ -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."""

View file

@ -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)

View file

@ -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