mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
Removing unnecessary get_mimetype.
This commit is contained in:
parent
a322d1a0a9
commit
c9e5884d4c
3 changed files with 5 additions and 5 deletions
|
|
@ -184,7 +184,7 @@ async def _refresh_files_list(paths: List[pathlib.Path], idempotency: datetime.d
|
|||
# Add any new files into the database.
|
||||
new_files = []
|
||||
if new_paths := (chunk - existing_paths):
|
||||
new_files = [File(path=i, idempotency=idempotency, mimetype=get_mimetype(i)) for i in new_paths]
|
||||
new_files = [File(path=i, idempotency=idempotency) for i in new_paths]
|
||||
session.add_all(new_files)
|
||||
# Apply models to all files. Many files will have no model.
|
||||
all_files = existing_files + new_files
|
||||
|
|
|
|||
|
|
@ -93,7 +93,8 @@ class File(ModelHelper, Base):
|
|||
|
||||
def do_index(self, force_index: bool = False):
|
||||
"""Gather any missing information about this file. Index the contents of this file using an Indexer."""
|
||||
self.do_stats()
|
||||
if not self.mimetype:
|
||||
self.do_stats()
|
||||
|
||||
try:
|
||||
if force_index or self.indexed is not True:
|
||||
|
|
@ -120,8 +121,7 @@ class File(ModelHelper, Base):
|
|||
|
||||
Returns True if the file has changed since last index. Change is detected by comparing old size, mimetype
|
||||
modification datetime."""
|
||||
from wrolpi.files.lib import split_path_stem_and_suffix, split_file_name_words
|
||||
from wrolpi.files.lib import get_mimetype
|
||||
from wrolpi.files.lib import split_path_stem_and_suffix, split_file_name_words, get_mimetype
|
||||
|
||||
old_mimetype = self.mimetype
|
||||
old_size = self.size
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ async def test_refresh_a_text_no_indexer(test_session, make_files_structure):
|
|||
@pytest.mark.asyncio
|
||||
async def test_refresh_many_files(test_session, make_files_structure):
|
||||
"""Used to profile file refreshing"""
|
||||
count = 1_000
|
||||
count = 10_000
|
||||
make_files_structure([f'{uuid4()}.txt' for _ in range(count)])
|
||||
with timer('first refresh'):
|
||||
await lib.refresh_files()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue