mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 15:06:19 -05:00
Changing archive special directory default to include domain tag.
This commit is contained in:
parent
6facb0856f
commit
2b0b161dad
8 changed files with 19 additions and 12 deletions
|
|
@ -378,7 +378,7 @@ class ArchiveFiles:
|
|||
|
||||
def get_archive_directory() -> pathlib.Path:
|
||||
archive_destination = get_wrolpi_config().archive_destination
|
||||
variables = dict(domain='', year='', month='', day='')
|
||||
variables = dict(domain='', domain_tag='', year='', month='', day='')
|
||||
archive_destination = archive_destination % variables
|
||||
archive_directory = get_media_directory() / archive_destination
|
||||
return archive_directory
|
||||
|
|
|
|||
|
|
@ -390,6 +390,7 @@ class Archive(Base, ModelHelper):
|
|||
|
||||
This uses the configured archive_destination template with variables:
|
||||
- domain: the domain name from the Collection
|
||||
- domain_tag: the tag name from the Collection (empty string if no tag)
|
||||
- year, month, day: current date
|
||||
|
||||
Returns:
|
||||
|
|
@ -397,9 +398,15 @@ class Archive(Base, ModelHelper):
|
|||
"""
|
||||
archive_destination = get_wrolpi_config().archive_destination
|
||||
|
||||
# Get the tag name from the collection if it exists
|
||||
domain_tag = ''
|
||||
if self.collection and self.collection.tag:
|
||||
domain_tag = self.collection.tag.name
|
||||
|
||||
now_ = now()
|
||||
variables = dict(
|
||||
domain=self.domain or 'unknown',
|
||||
domain_tag=domain_tag,
|
||||
year=now_.year,
|
||||
month=now_.month,
|
||||
day=now_.day,
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ async def test_archive_download_destination(async_client, test_session, test_dir
|
|||
assert str(archive.download_directory) == str(test_directory / 'archive/wrolpi.org')
|
||||
|
||||
# Year of download is supported.
|
||||
wrolpi_config.archive_destination = 'archives/%(domain)s/%(year)s'
|
||||
wrolpi_config.archive_destination = 'archives/%(domain_tag)s/%(domain)s/%(year)s'
|
||||
assert str(archive.download_directory) == str(test_directory / 'archives/wrolpi.org/2000')
|
||||
|
||||
# More download date is supported.
|
||||
wrolpi_config.archive_destination = 'archive/%(domain)s/%(year)s/%(month)s/%(day)s'
|
||||
wrolpi_config.archive_destination = 'archive/%(domain_tag)s/%(domain)s/%(year)s/%(month)s/%(day)s'
|
||||
assert str(archive.download_directory) == str(test_directory / 'archive/wrolpi.org/2000/1/2')
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue