diff --git a/controller/app/src/main/java/org/appdevforall/k2go/forgejo/data/ForgejoInstallPrefs.java b/controller/app/src/main/java/org/appdevforall/k2go/forgejo/data/ForgejoInstallPrefs.java
index 1c1840438..bfa9b4a58 100644
--- a/controller/app/src/main/java/org/appdevforall/k2go/forgejo/data/ForgejoInstallPrefs.java
+++ b/controller/app/src/main/java/org/appdevforall/k2go/forgejo/data/ForgejoInstallPrefs.java
@@ -23,7 +23,10 @@
*
*
Lifecycle (single owner of each transition, so the marker cannot leak):
*
- * - SET by the UI when a Forgejo install is committed ({@link #bankSeed}).
+ * - SET when a module batch that installs Forgejo starts ({@link #bankSeed(Context)}, called
+ * only by {@code ModuleProvisioner.startBatch}, the one path every install goes through:
+ * K2GO-592). A screen only records the repos opt-in ({@link #recordIncludeRepos}). The
+ * re-seed actions (Install repos, Retry of a failed seed) call {@link #bankSeed(Context, boolean)}.
* - CLEARED by the seed service (K2GO-423) on a seeded box, on a box with no Forgejo (the
* install did not land, so there is nothing to seed), or after {@link #MAX_ATTEMPTS} failed
* attempts (best-effort gives up rather than running forever).
@@ -44,7 +47,17 @@ private static SharedPreferences prefs(Context ctx) {
return ctx.getApplicationContext().getSharedPreferences(FILE, Context.MODE_PRIVATE);
}
- /** Bank a seed for the just-committed Forgejo install. {@code includeRepos} = seed the example repos too. */
+ /** Bank a seed for a Forgejo install batch. Keeps the repos opt-in that a screen recorded (default on). */
+ public static void bankSeed(Context ctx) {
+ bankSeed(ctx, includeRepos(ctx));
+ }
+
+ /** Record the repos opt-in for the next Forgejo install. No seed is owed until the batch starts. */
+ public static void recordIncludeRepos(Context ctx, boolean includeRepos) {
+ prefs(ctx).edit().putBoolean(KEY_INCLUDE_REPOS, includeRepos).apply();
+ }
+
+ /** Bank a seed with an explicit opt-in (a re-seed). {@code includeRepos} = seed the example repos too. */
public static void bankSeed(Context ctx, boolean includeRepos) {
prefs(ctx).edit()
.putBoolean(KEY_PENDING, true)
@@ -57,7 +70,7 @@ public static boolean isSeedPending(Context ctx) {
return prefs(ctx).getBoolean(KEY_PENDING, false);
}
- /** The opt-in for the example repos captured when the install was committed (default on). */
+ /** The opt-in for the example repos (default on). */
public static boolean includeRepos(Context ctx) {
return prefs(ctx).getBoolean(KEY_INCLUDE_REPOS, true);
}
diff --git a/controller/app/src/main/java/org/appdevforall/k2go/forgejo/domain/ForgejoSeedRule.java b/controller/app/src/main/java/org/appdevforall/k2go/forgejo/domain/ForgejoSeedRule.java
new file mode 100644
index 000000000..01549d71f
--- /dev/null
+++ b/controller/app/src/main/java/org/appdevforall/k2go/forgejo/domain/ForgejoSeedRule.java
@@ -0,0 +1,29 @@
+/*
+ * ============================================================================
+ * Name : ForgejoSeedRule.java
+ * Author : AppDevForAll
+ * Copyright : Copyright (c) 2026 AppDevForAll
+ * Description : K2GO-592. The rule for when a Forgejo seed is owed. The Forgejo role
+ * installs an empty forge; the seed adds the admin account, the org and the
+ * example repos. Every module batch that installs Forgejo owes a seed, from
+ * any install path.
+ * ============================================================================
+ */
+package org.appdevforall.k2go.forgejo.domain;
+
+public final class ForgejoSeedRule {
+
+ private ForgejoSeedRule() {}
+
+ /** The module key of Forgejo in the module catalog. */
+ public static final String FORGEJO = "forgejo";
+
+ /** True when the batch of module keys installs Forgejo. */
+ public static boolean owedBy(String[] modules) {
+ if (modules == null) return false;
+ for (String m : modules) {
+ if (FORGEJO.equals(m)) return true;
+ }
+ return false;
+ }
+}
diff --git a/controller/app/src/main/java/org/appdevforall/k2go/install/presentation/InstallService.java b/controller/app/src/main/java/org/appdevforall/k2go/install/presentation/InstallService.java
index 044db1c4d..a442b4a7b 100644
--- a/controller/app/src/main/java/org/appdevforall/k2go/install/presentation/InstallService.java
+++ b/controller/app/src/main/java/org/appdevforall/k2go/install/presentation/InstallService.java
@@ -1102,7 +1102,7 @@ private void startModuleStallWatch(final String moduleKey) {
// heartbeat — but this line says so in the log, so the missing backstop is noticed, not hidden.
if (moduleWriteDirRel(moduleKey) == null) {
log("[Stall] no write-dir backstop mapped for '" + moduleKey
- + "'; stall watch relies on the log heartbeat only");
+ + "'; stall watch relies on the log heartbeat and the Ansible temp dir");
}
moduleStallCheck = new Runnable() {
@Override public void run() {
@@ -1154,13 +1154,27 @@ private void hardStallKill(final String moduleKey, final int gen) {
if (prootEngine != null) prootEngine.killProcess();
}
- /** Total bytes under the module's write directory on the host rootfs, or -1 if unknown/absent. */
+ /**
+ * K2GO-592: Ansible get_url downloads into its own temp dir and moves the file to the module dir
+ * only at the end, so a long download grows this dir, not the module dir.
+ */
+ private static final String ANSIBLE_TMP_REL = "root/.ansible/tmp";
+
+ /**
+ * Total bytes under the module's write directory plus the Ansible temp dir on the host rootfs,
+ * or -1 if neither is there. A change in either one is movement.
+ */
private long moduleWriteDirSize(String key) {
+ if (debianRootfs == null) return -1L;
+ long total = -1L;
String rel = moduleWriteDirRel(key);
- if (rel == null || debianRootfs == null) return -1L;
- File d = new File(debianRootfs, rel);
- if (!d.isDirectory()) return -1L;
- return boundedDirSize(d, 20000);
+ for (String r : new String[]{rel, ANSIBLE_TMP_REL}) {
+ if (r == null) continue;
+ File d = new File(debianRootfs, r);
+ if (!d.isDirectory()) continue;
+ total = Math.max(total, 0L) + boundedDirSize(d, 20000);
+ }
+ return total;
}
/**
@@ -1179,7 +1193,7 @@ private static String moduleWriteDirRel(String key) {
case "maps": return "library/downloads/maps"; // aria2c logs a 60s summary here throughout the download
case "matomo": return "library/www/matomo";
case "kolibri": return "var/cache/apt/archives"; // chatty on stdout too; disk is the fallback
- case "forgejo": return "library/forgejo"; // K2GO-417: ~100 MB binary download from codeberg is silent to ansible; the growing binary here is the only progress signal (else the 360s hard-stall false-kills it)
+ case "forgejo": return "library/forgejo"; // K2GO-417: final home of the ~100 MB binary; while it downloads, the growth is in ANSIBLE_TMP_REL (K2GO-592)
default: return null;
}
}
diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleActionSheet.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleActionSheet.java
index 856d4983a..abeecd870 100644
--- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleActionSheet.java
+++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleActionSheet.java
@@ -263,17 +263,12 @@ public static void show(Activity act, String endpoint, String title, int iconRes
content.addView(row(ctx, R.drawable.ic_download_24, act.getString(R.string.k2go_sheet_install),
Emphasis.CAUTION, Operation.appInstall(key), false, v -> {
if (key != null) ModuleWishlist.add(ctx, key);
- // K2GO-417: bank the Forgejo repo seed (default-on) at the sheet install path too,
- // so a home-sheet install seeds the same as the detail screen (whose checkbox can
- // still override this before the install runs).
- if ("forgejo".equals(key)) org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs.bankSeed(ctx, true);
dlg.dismiss();
openHub(act);
}));
content.addView(row(ctx, R.drawable.ic_schedule_24, act.getString(R.string.k2go_sheet_schedule),
Emphasis.PLAIN, null, false, v -> {
if (key != null) ModuleWishlist.add(ctx, key);
- if ("forgejo".equals(key)) org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs.bankSeed(ctx, true);
dlg.dismiss();
if (onChanged != null) onChanged.run();
}));
diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleDetailFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleDetailFragment.java
index 511cf7286..0d0f8f516 100644
--- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleDetailFragment.java
+++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleDetailFragment.java
@@ -255,7 +255,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
if (isForgejo) org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs.clearSeed(requireContext());
} else {
ModuleWishlist.add(requireContext(), c.key());
- if (isForgejo) org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs.bankSeed(requireContext(), forgejoRepos.isChecked());
+ if (isForgejo) org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs.recordIncludeRepos(requireContext(), forgejoRepos.isChecked());
}
requireActivity().getOnBackPressedDispatcher().onBackPressed(); // back to the hub (shows ✓)
});
@@ -271,8 +271,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
((SetupLibraryActivity) getActivity()).openMapsChoose(); // ADFA-4958: maps needs its content selector first
} else {
ModuleWishlist.add(requireContext(), c.key());
- // K2GO-417: bank the seed with the opt-in captured on this screen before we leave it.
- if (isForgejo) org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs.bankSeed(requireContext(), forgejoRepos.isChecked());
+ // K2GO-417: record the repos opt-in of this screen; the batch start banks the seed (K2GO-592).
+ if (isForgejo) org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs.recordIncludeRepos(requireContext(), forgejoRepos.isChecked());
((SetupLibraryActivity) getActivity()).openModuleIndex();
}
}
diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleProvisioner.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleProvisioner.java
index 96186f5e5..a1709c073 100644
--- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleProvisioner.java
+++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleProvisioner.java
@@ -21,6 +21,8 @@
import android.os.Build;
import android.util.Log;
+import org.appdevforall.k2go.forgejo.data.ForgejoInstallPrefs;
+import org.appdevforall.k2go.forgejo.domain.ForgejoSeedRule;
import org.appdevforall.k2go.install.presentation.InstallService;
import org.appdevforall.k2go.install.presentation.ModuleQueueRepository;
import org.appdevforall.k2go.system.data.SystemDoor;
@@ -94,6 +96,9 @@ public static void startBatch(Context ctx, String[] modules, android.os.Bundle e
if (ctx == null || modules == null || modules.length == 0) return;
final Context app = ctx.getApplicationContext();
ModuleBatch.save(app, modules);
+ // K2GO-592: every Forgejo install owes its seed (admin account, org, repos), whatever screen
+ // scheduled it. Banked before the queue starts, so the install index sees it when the batch ends.
+ if (ForgejoSeedRule.owedBy(modules)) ForgejoInstallPrefs.bankSeed(app);
Intent i = new Intent(app, InstallService.class).setAction(InstallService.ACTION_START_MODULES);
i.putExtra(InstallService.EXTRA_MODULES, modules);
if (extras != null) i.putExtras(extras);
diff --git a/controller/app/src/test/java/org/appdevforall/k2go/forgejo/domain/ForgejoSeedRuleTest.java b/controller/app/src/test/java/org/appdevforall/k2go/forgejo/domain/ForgejoSeedRuleTest.java
new file mode 100644
index 000000000..457d5ef00
--- /dev/null
+++ b/controller/app/src/test/java/org/appdevforall/k2go/forgejo/domain/ForgejoSeedRuleTest.java
@@ -0,0 +1,29 @@
+package org.appdevforall.k2go.forgejo.domain;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class ForgejoSeedRuleTest {
+
+ @Test
+ public void batchWithForgejoOwesSeed() {
+ assertTrue(ForgejoSeedRule.owedBy(new String[]{"forgejo"}));
+ assertTrue(ForgejoSeedRule.owedBy(new String[]{"kolibri", "forgejo", "matomo"}));
+ }
+
+ @Test
+ public void batchWithoutForgejoOwesNoSeed() {
+ assertFalse(ForgejoSeedRule.owedBy(new String[]{"kolibri", "matomo"}));
+ assertFalse(ForgejoSeedRule.owedBy(new String[]{"Forgejo"}));
+ assertFalse(ForgejoSeedRule.owedBy(new String[]{"forgejo_extra"}));
+ }
+
+ @Test
+ public void emptyOrMissingBatchOwesNoSeed() {
+ assertFalse(ForgejoSeedRule.owedBy(new String[0]));
+ assertFalse(ForgejoSeedRule.owedBy(new String[]{null}));
+ assertFalse(ForgejoSeedRule.owedBy(null));
+ }
+}