mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Increasing archive file name character limit.
This commit is contained in:
parent
1d97f0e3a6
commit
b373992fed
2 changed files with 16 additions and 1 deletions
|
|
@ -70,6 +70,9 @@ def get_domain_directory(url: str) -> pathlib.Path:
|
|||
return directory
|
||||
|
||||
|
||||
MAXIMUM_ARCHIVE_FILE_CHARACTER_LENGTH = 200
|
||||
|
||||
|
||||
def get_new_archive_files(url: str, title: Optional[str]) -> ArchiveFiles:
|
||||
"""Create a list of archive files using a shared name schema. Raise an error if any of them exist."""
|
||||
directory = get_domain_directory(url)
|
||||
|
|
@ -77,7 +80,7 @@ def get_new_archive_files(url: str, title: Optional[str]) -> ArchiveFiles:
|
|||
dt = archive_strftime(now())
|
||||
|
||||
title = escape_file_name(title or 'NA')
|
||||
title = title[:50]
|
||||
title = title[:MAXIMUM_ARCHIVE_FILE_CHARACTER_LENGTH]
|
||||
prefix = f'{dt}_{title}'
|
||||
singlefile_path = directory / f'{prefix}.html'
|
||||
readability_path = directory / f'{prefix}.readability.html'
|
||||
|
|
|
|||
|
|
@ -298,6 +298,18 @@ async def test_get_title_from_html(test_session, fake_now):
|
|||
assert archive.title is None
|
||||
|
||||
|
||||
@skip_circleci
|
||||
def test_get_new_archive_files_length(fake_now):
|
||||
"""Archive titles are truncated to fit file system length limit. (255-character limit for most file systems)"""
|
||||
fake_now(datetime(2001, 1, 1))
|
||||
archive_files = get_new_archive_files('https://example.com', 'a' * 500)
|
||||
assert len(str(archive_files.singlefile.name)) == 225
|
||||
assert len(str(archive_files.readability.name)) == 237
|
||||
assert len(str(archive_files.readability_txt.name)) == 236
|
||||
assert len(str(archive_files.readability_json.name)) == 237
|
||||
assert len(str(archive_files.screenshot.name)) == 224
|
||||
|
||||
|
||||
@skip_circleci
|
||||
def test_get_new_archive_files(fake_now):
|
||||
"""Archive files have a specific format so they are sorted by datetime, and are near each other."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue