repos: a clone is owned by a random token, not its URL

The ownership marker held the Repo's URL key, which anyone can write, so
a copied clone, an extracted archive or a hand-made `.git` passed the
check and was reset and cleaned.  Each Repo now has a random clone_token
(repository column and repos.yaml, so a Repo restored from the config
still owns its clone); the marker holds it, and only a clone holding the
Repo's token is updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-10-06 18:58:18 -06:00
parent a1d4c42eee
commit d0ea6ab313
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
6 changed files with 116 additions and 20 deletions

View file

@ -16,7 +16,10 @@ async def test_dump_and_import(test_session, test_directory, async_client, test_
config = lib.get_repos_config()
assert config.get_file().is_file()
assert config.repos == [
# Each Repo's random clone token is kept, so a restored Repo still owns its clone.
dumped = [dict(i) for i in config.repos]
assert all(len(i.pop('clone_token')) == 32 for i in dumped)
assert dumped == [
dict(name='b', url='https://github.com/a/b', directory='repos/b', tag_name=None, description=None,
mode='snapshot', branch='dev', submodules=False, frequency=DownloadFrequency.weekly),
dict(name='kiwix-tools', url='https://github.com/kiwix/kiwix-tools', directory='repos/software/kiwix-tools',