Interrupted bare clone (`clone_kept_releases`) leaves unborn HEAD and permanently breaks update checks (`Failed to get repo HEAD`)

オープン
#14 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
53/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
git, rust
領域
backend, devtools

調査の方向性

Start with src-tauri/src/git.rs, especially clone_kept_releases, ensure_repository, and the repo.head() call in get_tags_and_current_version; read the existing repository tests and trace how app.current_version is stored. Reproduce with an existing bare repo whose HEAD points to a missing branch, then check how recovery should work alongside interrupted clones. Done means the version list can load after this failure; the issue suggests atomic cloning and unborn-HEAD recovery, with tests in git.rs.

索引モデルが issue の本文から書いたものです。

説明

Summary

In PyAppify v1.2.9 (dceecfb), if clone_kept_releases is interrupted mid-way (e.g. the launched app kills the launcher via "Kill Launcher After Start" while a background re-clone is still fetching tags), data/apps/<app>/repo is left behind as a valid-looking bare repo with an unborn HEAD (ref: refs/heads/master, refs/heads/ empty).

Afterward, ensure_repository treats the repo as valid and only syncs tags, while get_tags_and_current_version fails unconditionally on repo.head(), permanently breaking version checks and updates (Failed to load app: Failed to get repo HEAD).

Root Cause (v1.2.9 / dceecfb)
  1. Non-atomic in-place init_bare (src-tauri/src/git.rs): clone_kept_releases (L556) initializes directly at the final repo path (default HEAD = ref: refs/heads/master), fetches only tags, and relies on checkout_detached later in ensure_repository (L1499) to set a valid HEAD. .inspect_err cleanup (L1429–L1431) does not run when the process is terminated externally.
  2. Race with start_app + launcher kill (src-tauri/src/app_service.rs): load_app emits app.json (installed: true) at L458 before update_app_from_disk() (L460). start_app (L1652) does not wait for ensure_repository, so the app can start and kill the launcher while the re-clone is still running.
  3. No unborn-HEAD recovery (src-tauri/src/git.rs): Subsequent ensure_repository calls succeed at open_repository (L1357) and only run sync_tags, then get_tags_and_current_version always fails at repo.head() (L1264).
Launcher log excerpt (Windows, ok-nte, keep_releases: 30)
# 1. Invalid repo removed; in-place bare re-clone starts (31 tags)
2026-11-30 23:50:32.603 WARN pyappify_lib::git: Directory at ...\repo exists but is not a valid git repository (...). Removing and re-cloning.
2026-11-30 23:50:32.608 INFO [ok-nte]: Attempting to clone https://cnb.cool/BnanZ0/ok-nte-update.git into ...\repo
2026-11-30 23:50:33.071 INFO [ok-nte]: Fetching the 31 newest version(s) of 30 releases kept.

# 2. App starts 12s later and kills the launcher before clone finishes
2026-11-30 23:50:45.165 INFO pyappify_lib::app_service: Attempting to start app: ok-nte
2026-11-30 23:50:52.084 INFO [ok-nte]: ... MainWindow showEvent Kill Launcher After Start
2026-11-30 23:50:52.084 INFO [ok-nte]: ... Attempting to terminate process with PID: 14364

# 3. Subsequent CLI --get-version-list sees an "existing" bare repo, finishes fetching tags, then fails on unborn HEAD
2026-11-30 23:50:53.224 INFO [ok-nte]: Repository already exists ...\repo
2026-11-30 23:51:44.275 INFO [ok-nte]: Fetch complete.
2026-11-30 23:51:44.275 INFO [ok-nte]: Fetching all tags for repository at ...\repo
# -> App log: RuntimeError: Failed to load app: Failed to get repo HEAD
Minimal Repro & Workaround
  • Repro: Set data/apps/<app>/repo/HEAD to ref: refs/heads/master (nonexistent branch) and run <app>.exe --get-version-list --number-versions 10 --release-only true --response-file out.json → {"error":"Failed to load app: Failed to get repo HEAD"}.
  • Workaround: git --git-dir="data/apps/<app>/repo" update-ref --no-deref HEAD <installed-tag-commit-oid> (or delete repo and let the launcher finish re-cloning).
Suggested Fix
  1. Atomic clone: Clone into a temporary sibling dir (e.g. repo.cloning), finish fetching tags and setting initial detached HEAD, then atomically rename to repo (cleaning up leftover temp dirs on startup).
  2. Self-heal unborn HEAD: In ensure_repository, validate repo.head() on existing repos; if unborn/unresolvable, detach HEAD to app.current_version (or latest release tag / re-clone) so already-affected installs recover automatically.
  3. (Optional) Prevent start_app from launching (and killing the launcher) while a fresh/re-clone is in progress.

Happy to submit a PR with unit tests in git.rs if this direction sounds good!

主要言語
Rust
スター
75
フォーク
13
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ok-oldking/pyappify のほかの issue

ok-oldking/pyappify の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。