diff --git a/crates/coa-core/src/update.rs b/crates/coa-core/src/update.rs index 9c7b7bf..96c3ba9 100644 --- a/crates/coa-core/src/update.rs +++ b/crates/coa-core/src/update.rs @@ -197,8 +197,15 @@ pub struct PlanItem { /// What an update would do to this installation. Read-only. pub fn plan(root: &Path, meta: &InstallMeta, manifest: &Manifest, resolutions: &BTreeMap, staged: Option<&Path>) -> Result> { let mut out = Vec::new(); + // An update is decided by version. The same version has the same files, so a file the owner edited (or removed) + // is not an update: Repair lists such files and restores them on request. + let same_version = meta.core.version.as_deref().is_some_and(|installed| installed == manifest.version); for f in manifest.files.iter().filter(|f| !f.path.starts_with(STAGED_PREFIX)) { let target = fsx::ensure_within(root, &fsx::safe_join(root, &f.path)?)?; + if same_version { + out.push(PlanItem { path: f.path.clone(), action: Action::Skip, reason: Some("same version; Repair restores changed files".into()) }); + continue; + } let cur = sha_if_exists(&target); let recorded = meta.original_hashes.get(&f.path); let (action, reason) = match (f.policy, &cur) { @@ -1170,6 +1177,11 @@ mod tests { changed.files.iter_mut().find(|file| file.path == "Scripts/manage.py").unwrap().sha256 = fsx::sha256_bytes(b"new launcher"); assert!(launcher_already_integrated(&w.root, &w.meta, &meta, &changed, &Source::Dir(w.pkg.clone())).is_err()); write(&w.root, "Scripts/manage.py", format!("{integrated}\n# user edit\n").as_bytes()); + // Same version: the owner's edit is not an update (Repair lists and restores it). + let p = preview(&w.root, &meta, &Source::Dir(w.pkg.clone()), &w.key, &BTreeMap::new()).unwrap(); + assert!(p.items.iter().all(|item| item.action == Action::Skip) && p.conflicts.is_empty()); + // An older installed build with the same edit does need a decision. + meta.core.version = Some("1.0.0".into()); let p = preview(&w.root, &meta, &Source::Dir(w.pkg.clone()), &w.key, &BTreeMap::new()).unwrap(); assert_eq!(p.items.iter().find(|item| item.path == "Scripts/manage.py").unwrap().action, Action::Conflict); meta.original_hashes.insert("Scripts/manage.py".into(), fsx::sha256_file(&w.root.join("Scripts/manage.py")).unwrap()); diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 16677cd..12f3538 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -32,6 +32,8 @@ const en = { "repair.result": "Restored files: {files}. Applied database updates: {sql}.", "repair.backup": "Backup: {id}", "repair.fileCount": "Files that differ or are missing: {n}", + "repair.fileMissing": "missing", + "repair.fileChanged": "changed", "repair.dbCount": "Schema/start-data problems: {columns}. Pending or failed SQL updates: {sql}.", "repair.limited": "This older package has no full schema contract. Only character-save columns and starting data are checked.", "repair.unresolved": "Database problems remain. Repair does not replay already applied SQL or invent column changes. Export diagnostics with the listed problems for a corrective server update.", diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index 319f4b0..0880437 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -34,6 +34,8 @@ const ru: Partial> = { "repair.result": "Восстановлено файлов: {files}. Применено обновлений БД: {sql}.", "repair.backup": "Резервная копия: {id}", "repair.fileCount": "Изменённых или отсутствующих файлов: {n}", + "repair.fileMissing": "нет файла", + "repair.fileChanged": "изменён", "repair.dbCount": "Проблем структуры БД/стартовых данных: {columns}. Ожидающих или неудачных SQL: {sql}.", "repair.limited": "В старом пакете нет полного описания схемы. Проверяются только колонки сохранения персонажей и стартовые данные.", "repair.unresolved": "Проблемы БД остались. Repair не повторяет уже применённые SQL и не добавляет колонки наугад. Экспортируйте диагностику с этим списком для исправляющего обновления сервера.", diff --git a/src/screens/RepairCard.tsx b/src/screens/RepairCard.tsx index 3368c44..9d3f23d 100644 --- a/src/screens/RepairCard.tsx +++ b/src/screens/RepairCard.tsx @@ -10,7 +10,7 @@ export function RepairCard({ serverId }: { serverId: string }) { const job = useRepair(serverId); const [checking, setChecking] = useState(false); const [database, setDatabase] = useState(null); - const [files, setFiles] = useState<{ path: string; kind: string }[] | null>(null); + const [files, setFiles] = useState<{ path: string; kind: "missing" | "changed" | string }[] | null>(null); const [error, setError] = useState(null); async function check() { clearRepairResult(serverId); @@ -36,6 +36,12 @@ export function RepairCard({ serverId }: { serverId: string }) { {job.result.error &&

{job.result.error}

} } {files && !job.result &&

{t("repair.fileCount", { n: files.length })}

} + {files && !job.result && files.length > 0 && ( +
    + {files.slice(0, 200).map((f) =>
  • {t(f.kind === "missing" ? "repair.fileMissing" : "repair.fileChanged")} {f.path}
  • )} + {files.length > 200 &&
  • …
  • } +
+ )} {checks?.map(c => { const pending = c.migrations.filter(m => m.status !== "applied"); return