mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-05 14:19:56 -05:00
Bumping version for new feature.
Skipping video epoch test on circleci. Created script which finds and cleans up (renames/deletes) orphaned video meta files. Reworking orphaned video query, some video files were leaking through. Modifying File table to allow finding of orphaned video files. Extracting epoch from video info_json for more accurate upload_date. Extracting epoch from video info_json for more accurate upload_date.
This commit is contained in:
parent
b216a9c678
commit
d0d69519cd
10 changed files with 347 additions and 30 deletions
|
|
@ -22,14 +22,17 @@ class File(ModelHelper, Base):
|
|||
path: pathlib.Path = Column(MediaPathType, primary_key=True)
|
||||
|
||||
associated = Column(Boolean, default=False)
|
||||
directory: pathlib.Path = Column(MediaPathType) # aka the parent.
|
||||
full_stem = Column(String) # f'{directory}/{stem}'
|
||||
idempotency = Column(TZDateTime, default=lambda: now())
|
||||
indexed = Column(Boolean, default=False)
|
||||
mimetype = Column(String)
|
||||
model = Column(String)
|
||||
mimetype = Column(String) # Gotten by python-magic or file command.
|
||||
model = Column(String) # Filled out by the modeler. Will be the table name (video, archive, etc.).
|
||||
modification_datetime = Column(TZDateTime)
|
||||
size = Column(Integer)
|
||||
suffix = Column(String)
|
||||
title = Column(String)
|
||||
stem = Column(String) # The file name, but without the suffix (aka extension). See: split_path_stem_and_suffix
|
||||
suffix = Column(String) # aka the extension.
|
||||
title = Column(String) # Provided by the modeler, or it will be the entire file name (with suffix).
|
||||
|
||||
a_text = deferred(Column(String))
|
||||
b_text = deferred(Column(String))
|
||||
|
|
@ -53,12 +56,15 @@ class File(ModelHelper, Base):
|
|||
path = self.path.relative_to(get_media_directory())
|
||||
d = dict(
|
||||
associated=self.associated,
|
||||
directory=self.directory,
|
||||
full_stem=self.full_stem,
|
||||
key=path, # React browser expects this.
|
||||
mimetype=self.mimetype,
|
||||
model=self.model,
|
||||
modified=self.modification_datetime, # React browser expects this.
|
||||
path=path,
|
||||
size=self.size,
|
||||
stem=self.stem,
|
||||
suffix=self.suffix,
|
||||
title=self.title,
|
||||
)
|
||||
|
|
@ -122,11 +128,13 @@ class File(ModelHelper, Base):
|
|||
if not self.mimetype:
|
||||
from wrolpi.files.lib import get_mimetype
|
||||
self.mimetype = get_mimetype(self.path)
|
||||
self.stem, self.suffix = split_path_stem_and_suffix(self.path)
|
||||
self.directory = self.path.parent
|
||||
self.full_stem = f'{self.directory}/{self.stem}'
|
||||
self.title = self.title or self.path.name
|
||||
stat = self.path.stat()
|
||||
self.size = stat.st_size
|
||||
self.modification_datetime = from_timestamp(stat.st_mtime)
|
||||
name, self.suffix = split_path_stem_and_suffix(self.path)
|
||||
|
||||
changed = old_mimetype != self.mimetype \
|
||||
or old_size != self.size \
|
||||
|
|
@ -135,7 +143,7 @@ class File(ModelHelper, Base):
|
|||
if changed:
|
||||
self.indexed = False
|
||||
# Use title as the a_text temporarily, this may be overwritten by indexer.
|
||||
self.a_text = self.a_text or name
|
||||
self.a_text = self.a_text or self.stem
|
||||
return changed
|
||||
|
||||
@validates('path')
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ async def test_mime_type(test_session, make_files_structure, test_directory):
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_files_indexer(test_session, make_files_structure):
|
||||
async def test_files_indexer(test_session, make_files_structure, test_directory):
|
||||
"""An Indexer is provided for each file based on it's mimetype or contents."""
|
||||
source_files: List[str] = [
|
||||
'a bzip file.bzip',
|
||||
|
|
@ -318,15 +318,18 @@ async def test_files_indexer(test_session, make_files_structure):
|
|||
assert info_json_file.path.suffix == '.json' and info_json_file.indexer == indexers.DefaultIndexer
|
||||
assert video_file.path.suffix == '.mp4' and video_file.indexer == videos.VideoIndexer
|
||||
|
||||
# Path suffix is copied to File.suffix.
|
||||
assert bzip_file.suffix == '.bzip'
|
||||
assert gzip_file.suffix == '.gzip'
|
||||
assert text_file.suffix == '.txt'
|
||||
assert zip_file.suffix == '.zip'
|
||||
assert image_file.suffix == '.jpeg'
|
||||
assert unknown_file.suffix == ''
|
||||
assert info_json_file.suffix == '.info.json'
|
||||
assert video_file.suffix == '.mp4'
|
||||
# Suffix, directory and name are correct.
|
||||
def assert_file_properties(file: File, suffix, directory, stem):
|
||||
assert file.suffix == suffix and file.directory == directory and file.stem == stem
|
||||
|
||||
assert_file_properties(bzip_file, '.bzip', test_directory, 'a bzip file')
|
||||
assert_file_properties(gzip_file, '.gzip', test_directory, 'a gzip file')
|
||||
assert_file_properties(text_file, '.txt', test_directory, 'a text file')
|
||||
assert_file_properties(zip_file, '.zip', test_directory, 'a zip file')
|
||||
assert_file_properties(image_file, '.jpeg', test_directory / 'images', 'an image file')
|
||||
assert_file_properties(unknown_file, '', test_directory, 'unknown file')
|
||||
assert_file_properties(info_json_file, '.info.json', test_directory / 'videos', 'a video file')
|
||||
assert_file_properties(video_file, '.mp4', test_directory / 'videos', 'a video file')
|
||||
|
||||
# File are indexed by their titles and contents.
|
||||
files, total = lib.search_files('file', 10, 0)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
__version__ = '0.7.5-beta'
|
||||
__version__ = '0.7.6-beta'
|
||||
|
||||
import subprocess
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue