Removing FileGroup.full_stem in favor of primary_path. This is to handle when two unrelated files share a name ('some text.txt' and 'some text.jpg').

This commit is contained in:
Roland 2023-04-09 16:59:20 -06:00
parent e557b0157e
commit 18273286dc
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
12 changed files with 120 additions and 77 deletions

View file

@ -486,7 +486,7 @@ def test_refresh_archives(test_session, test_directory, test_client, make_files_
# Cause a re-index of the archive.
test_session.query(FileGroup).filter_by(
full_stem=str(test_directory / 'archive/example.com/2021-10-05-16-20-10_NA')).one().indexed = False
primary_path=str(test_directory / 'archive/example.com/2021-10-05-16-20-10_NA.html')).one().indexed = False
test_session.commit()
# Running the refresh does not result in a new archive.

View file

@ -608,7 +608,7 @@ def find_orphaned_video_files(directory: pathlib.Path) -> Generator[pathlib.Path
FROM file_group
WHERE
mimetype NOT LIKE 'video%'
AND full_stem LIKE '{directory}/%'
AND primary_path LIKE '{directory}/%'
''')
results = (pathlib.Path(j['path']) for i in curs.fetchall() for j in i[0])
yield from results

View file

@ -73,10 +73,9 @@ def test_refresh_videos(test_client, test_session, test_directory, simple_channe
# Create a bogus video in the channel.
video_file = test_directory / 'foo.mp4'
with get_db_curs(commit=True) as curs:
full_stem, _ = split_path_stem_and_suffix(video_file, full=True)
stmt = "INSERT INTO file_group (mimetype, full_stem, primary_path, indexed, files, model)" \
" values ('video/mp4', %(full_stem)s, %(primary_path)s, true, %(files)s, 'video') RETURNING id"
params = {'full_stem': full_stem, 'primary_path': str(video_file), 'files': list()}
stmt = "INSERT INTO file_group (mimetype, primary_path, indexed, files, model)" \
" values ('video/mp4', %(primary_path)s, true, %(files)s, 'video') RETURNING id"
params = {'primary_path': str(video_file), 'files': list()}
curs.execute(stmt, params)
video4_id = curs.fetchall()[0][0]
stmt = "INSERT INTO video (file_group_id) values (%(video_id)s)"