mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 09:56:17 -05:00
repos.yaml imports by diffing
repos.yaml declares one section, its Repos keyed by repo_url_key (another URL of the same Repo is that Repo), comparing name, description, directory, Tag, mode, branch, submodules, frequency and clone token (a missing directory or clone token keeps the database's). An unchanged import writes nothing (every import rewrote every Repo and its Download). An invalid entry is skipped and counted, and its Repo is kept; before, a Repo whose entry failed validation was deleted. New Repos are created inside the import's one write: recurring_download (via get_or_create_download and _set_repository_download) takes commit=False, and the URL is not looked up again for each new Repo (O(N^2)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
adbcf944a5
commit
deba43366a
6 changed files with 253 additions and 113 deletions
|
|
@ -277,11 +277,11 @@ async def test_repo_directory_traversal(test_session, test_directory, async_clie
|
|||
lib.create_repository(test_session, 'https://github.com/a/b', directory=test_directory)
|
||||
test_session.rollback()
|
||||
|
||||
# The config can not move an existing Repo outside the media directory.
|
||||
# The config can not move an existing Repo outside the media directory: the entry is invalid (and skipped).
|
||||
lib.create_repository(test_session, 'https://github.com/a/b')
|
||||
with pytest.raises(InvalidRepo):
|
||||
lib.ReposConfig._import_repo(test_session, dict(url='https://github.com/a/b', directory='../outside'))
|
||||
test_session.rollback()
|
||||
entry = dict(url='https://github.com/a/b', directory='../outside')
|
||||
rows, invalid = lib.ReposSection().file_rows(dict(repos=[entry]))
|
||||
assert (rows, invalid) == (dict(), {lib.repo_url_key('https://github.com/a/b')})
|
||||
assert test_session.query(Repository).one().directory == test_directory / 'repos/b'
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue