{"record":{"id":"4b76a6a74a64cfec","repo":"gitbutlerapp/gitbutler","slug":"there-were-already-max-attempts-backup-project-f","errorCode":null,"errorMessage":"There were already {max_attempts} backup project files - giving up","messagePattern":"There were already (.+?) backup project files - giving up","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/gitbutler-project/src/controller.rs","lineNumber":156,"sourceCode":"                    if backup_path.is_file() {\n                        continue;\n                    }\n\n                    if let Err(err) = std::fs::rename(&projects_path, &backup_path) {\n                        tracing::error!(\n                            \"Failed to rename {} to {} - application may fail to startup: {err}\",\n                            projects_path.display(),\n                            backup_path.display()\n                        );\n                    }\n\n                    bail!(\n                        \"Could not open projects file at '{}'.\\nIt was moved to {}.\\nReopen or refresh the app to start fresh.\\nError was: {probably_file_load_err}\",\n                        projects_path.display(),\n                        backup_path.display()\n                    );\n                }\n                bail!(\"There were already {max_attempts} backup project files - giving up\")\n            }\n        }\n    }\n}\n\nimpl Controller {\n    pub(crate) fn from_path(path: impl Into<PathBuf>) -> Self {\n        let path = path.into();\n        Self {\n            projects_storage: storage::Storage::from_path(&path),\n            local_data_dir: path,\n        }\n    }\n\n    pub(crate) fn add_with_best_effort<P: AsRef<Path>>(\n        &self,\n        worktree_dir: P,\n    ) -> Result<AddProjectOutcome> {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-project/src/controller.rs#L138-L174","documentation":"At startup, GitButler's project Controller validates the projects database file. If the file is corrupt/unreadable, it moves it aside to a numbered backup (projects.backup.N) and starts fresh. If it fails to create a fresh backup after max_attempts tries (backup names already taken or rename keeps failing), it gives up with this error rather than risk data loss or an unusable state.","triggerScenarios":"Calling assure_app_can_startup_or_fix_it when the projects file fails to load AND each attempted backup path (projects.backup.0..N) already exists or the rename to backup cannot succeed for max_attempts consecutive tries.","commonSituations":"Corrupted projects database after a crash or disk-full; many stale projects.backup.* files left over from repeated failed startups; read-only filesystem or permissions blocking renames; sync tools (Dropbox) locking the projects file.","solutions":["Inspect the projects storage directory and delete or archive old projects.backup.* files so a fresh backup slot is available.","Check filesystem permissions and free disk space; the rename of the projects file must be able to succeed.","Restore the projects file from a known-good backup, or delete the corrupt projects file (losing project list) and let the app recreate it.","Close file-locking programs (sync clients, editors, antivirus) and restart the app."],"exampleFix":"// Too many stale backups block recovery\n$ ls ~/.local/share/gitbutler/projects.backup.*\n// after\n$ mkdir -p ~/backup-archive\n$ mv ~/.local/share/gitbutler/projects.backup.* ~/backup-archive/","handlingStrategy":"validation","validationCode":"let dir = projects_path.parent().unwrap();\nlet stale: Vec<_> = std::fs::read_dir(dir)?\n    .filter_map(|e| e.ok())\n    .filter(|e| e.file_name().to_string_lossy().starts_with(\"projects.backup.\"))\n    .collect();\nif stale.len() >= max_attempts {\n    // archive stale backups before startup recovery runs\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Periodically clean projects.backup.* files from the storage directory.","Ensure adequate disk space and write permissions for the app data dir.","Avoid placing the app data dir inside sync-client folders."],"tags":["startup","backup","file-rename","corruption","rust"],"backgroundTag":"file-already-exists","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}