mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-10-20 03:37:59 +00:00
bug: always keep existing package version in archive
This commit is contained in:
1 parent
b73be7abcc
commit
81ea175034
4 files changed
+15
-7
No files matched your search
@@ -87,7 +87,12 @@ class ArchiveRotationTrigger(Trigger):
|
|||||||
if self.keep_built_packages == 0:
|
if self.keep_built_packages == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
to_remove = repository.package_archives(package.base)
|
current = next(iter(repository.packages([package.base])), None)
|
||||||
|
to_remove = [
|
||||||
|
single
|
||||||
|
for single in repository.package_archives(package.base)
|
||||||
|
if current is None or single.version != current.version
|
||||||
|
]
|
||||||
|
|
||||||
for single in to_remove[:-self.keep_built_packages]:
|
for single in to_remove[:-self.keep_built_packages]:
|
||||||
self.logger.info("removing version %s of package %s", single.version, single.base)
|
self.logger.info("removing version %s of package %s", single.version, single.base)
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ def test_configuration_sections(configuration: Configuration) -> None:
|
|||||||
def test_archives_remove(archive_rotation_trigger: ArchiveRotationTrigger, package_ahriman: Package,
|
def test_archives_remove(archive_rotation_trigger: ArchiveRotationTrigger, package_ahriman: Package,
|
||||||
repository: Repository, mocker: MockerFixture) -> None:
|
repository: Repository, mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
must remove older packages
|
must keep the current package and the configured amount of additional packages
|
||||||
"""
|
"""
|
||||||
packages = []
|
packages = []
|
||||||
for i in range(5):
|
for i in range(1, 7):
|
||||||
generated = replace(package_ahriman, version=str(i))
|
generated = replace(package_ahriman, version=str(i))
|
||||||
generated.packages = {
|
generated.packages = {
|
||||||
key: replace(value, filename=str(i))
|
key: replace(value, filename=str(i))
|
||||||
@@ -33,14 +33,17 @@ def test_archives_remove(archive_rotation_trigger: ArchiveRotationTrigger, packa
|
|||||||
}
|
}
|
||||||
packages.append(generated)
|
packages.append(generated)
|
||||||
|
|
||||||
|
archive_rotation_trigger.keep_built_packages = 2
|
||||||
|
mocker.patch.object(repository, "packages", return_value=[replace(package_ahriman, version="3")])
|
||||||
mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives", return_value=packages)
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives", return_value=packages)
|
||||||
mocker.patch("pathlib.Path.glob", return_value=[Path(str(i)) for i in range(5)])
|
mocker.patch("pathlib.Path.glob", side_effect=lambda pattern: [Path(pattern.removesuffix("*"))])
|
||||||
unlink_mock = mocker.patch("pathlib.Path.unlink", autospec=True)
|
unlink_mock = mocker.patch("pathlib.Path.unlink", autospec=True)
|
||||||
|
|
||||||
archive_rotation_trigger.archives_remove(package_ahriman, repository)
|
archive_rotation_trigger.archives_remove(package_ahriman, repository)
|
||||||
unlink_mock.assert_has_calls([
|
unlink_mock.assert_has_calls([
|
||||||
MockCall(Path("0")),
|
|
||||||
MockCall(Path("1")),
|
MockCall(Path("1")),
|
||||||
|
MockCall(Path("2")),
|
||||||
|
MockCall(Path("4")),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ Web server settings. This feature requires ``aiohttp`` libraries to be installed
|
|||||||
|
|
||||||
Describes settings for packages archives management extensions.
|
Describes settings for packages archives management extensions.
|
||||||
|
|
||||||
* ``keep_built_packages`` - keep this amount of built packages with different versions, integer, required. ``0`` will effectively disable archives removal.
|
* ``keep_built_packages`` - keep this amount of additional built package versions alongside the version currently published in the repository, integer, required. ``0`` will effectively disable archives removal.
|
||||||
|
|
||||||
``keyring`` group
|
``keyring`` group
|
||||||
-----------------
|
-----------------
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ This trigger will be called right after build process (``on_result``). It will p
|
|||||||
``ahriman.core.housekeeping.ArchiveRotationTrigger``
|
``ahriman.core.housekeeping.ArchiveRotationTrigger``
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
This trigger removes old package versions from the archive directory. It implements ``on_result`` and, after each build, compares available versions for updated packages and removes the older ones, keeping only the last N versions as configured by ``keep_built_packages`` option.
|
This trigger removes old package versions from the archive directory. It implements ``on_result`` and, after each build, compares available versions for updated packages and removes older ones, keeping the version currently published in the repository plus the last N other versions as configured by ``keep_built_packages`` option.
|
||||||
|
|
||||||
``ahriman.core.housekeeping.LogsRotationTrigger``
|
``ahriman.core.housekeeping.LogsRotationTrigger``
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|||||||
Reference in new issue
Block a user