Linking to uploaded file on download after a user uploads a file with the same URL.
Some checks failed
CodeQL / Analyze (push) Has been cancelled

This commit is contained in:
Roland 2025-08-11 16:54:10 -06:00
parent db956faedf
commit 76a454ea34
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
7 changed files with 91 additions and 39 deletions

View file

@ -107,6 +107,25 @@ archive_downloader = ArchiveDownloader()
def model_archive(file_group: FileGroup, session: Session = None) -> Archive:
"""
Models an Archive from a given FileGroup.
This function takes in a FileGroup and attempts to create an Archive object.
It does this by checking for the presence of HTML files within the FileGroup,
determining if any of these are SingleFiles, and then extracting relevant data
(title, contents) from either the JSON or text readability files.
Args:
file_group: The FileGroup to model as an Archive.
session: An optional database session for committing changes.
Returns:
An Archive object representing the modeled archive.
Raises:
InvalidArchive: If no HTML SingleFile is found in the FileGroup, or if
any other error occurs during modeling.
"""
file_group_id = file_group.id
if not file_group_id:
session.flush([file_group])

View file

@ -315,3 +315,14 @@ def test_browser_profile_to_yt_dlp_arg(file_name, expected):
"""
file_name = pathlib.Path(file_name)
assert lib.browser_profile_to_yt_dlp_arg(file_name) == expected
def test_video_location(test_session, video_factory, channel_factory):
# Video location without a channel, it opens the preview.
video1 = video_factory(title='vid1')
assert video1.location == '/videos/video/1'
# Video location with a channel.
channel = channel_factory(name='ChannelName')
video2 = video_factory(title='vid2', channel_id=channel.id)
assert video2.location == '/videos/channel/1/video/2'