{"record":{"id":"2678a2279c1fdbf7","repo":"gitbutlerapp/gitbutler","slug":"database-file-at-db-path-has-max-attempts-cor","errorCode":null,"errorMessage":"Database file at '{db_path} has {max_attempts} corrupted copies - giving up, application probably won't work","messagePattern":"Database file at '(.+?) has (.+?) corrupted copies - giving up, application probably won't work","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/gitbutler-tauri/src/projects.rs","lineNumber":156,"sourceCode":"            if backup_path.is_file() {\n                continue;\n            }\n\n            if let Err(err) = std::fs::rename(&db_path, &backup_path) {\n                bail!(\n                    \"Failed to rename {} to {} - application may fail to startup: {err}\",\n                    db_path.display(),\n                    backup_path.display()\n                );\n            }\n\n            return Ok(Some(format!(\n                \"Could not open db file at '{}'.\\nIt was moved to {} for recovery. \\n\\nError was: {err}\",\n                db_path.display(),\n                backup_path.display()\n            )));\n        }\n        bail!(\n            \"Database file at '{db_path} has {max_attempts} corrupted copies - giving up, application probably won't work\",\n            db_path = db_path.display()\n        );\n    }\n    Ok(None)\n}\n\n/// Return an error message that\nfn warn_about_filters_and_git_lfs(repo: &gix::Repository) -> anyhow::Result<Option<String>> {\n    let index = repo.index_or_empty()?;\n    let mut cache = repo.attributes_only(\n        &index,\n        gix::worktree::stack::state::attributes::Source::WorktreeThenIdMapping,\n    )?;\n    let mut attrs = cache.selected_attribute_matches(Some(\"filter\"));\n    let mut all_filters = BTreeSet::<String>::new();\n    let mut files_with_filter = Vec::new();\n    for entry in index.entries() {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-tauri/src/projects.rs#L138-L174","documentation":"assure_database_valid in the Tauri project handler verifies the project's SQLite database can be opened. When the file is corrupt it is backed up and recreated, retrying up to max_attempts times; if every attempt still yields a corrupt database, it bails with this fatal message because the application cannot function without a working project database.","triggerScenarios":"Opening/activating a project whose sqlite file is corrupt; the repair loop (move corrupt file to backup, recreate) has already run max_attempts times and each freshly created copy is still unreadable.","commonSituations":"Disk full or I/O errors during writes, abrupt process kill mid-write leaving a corrupt WAL/journal, antivirus or sync tools (Dropbox/OneDrive) locking or mangling the db file, failing disk, or db path pointing at a directory/locked file so every new copy fails too.","solutions":["Check free disk space and fix underlying I/O problems (full disk, failing drive, AV/sync interference)","Look for the .bak/recovery copies next to the db path; inspect them to recover data, then close all GitButler processes and restart","Delete the corrupted db file(s) so a clean database can be created (project metadata will be re-derived from git)","If it persists, run sqlite3 integrity checks / update SQLite and report with logs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before activating a project\nlet db_path = project.db_path();\nif !db_path.parent().map(|p| p.writable()).unwrap_or(false) { /* alert user: db dir not writable */ }\n// check free space and that db_path is not a directory","typeGuard":null,"tryCatchPattern":"match result {\n  Err(e) if e.to_string().contains(\"corrupted copies\") => {\n    // show fatal dialog: advise closing app, freeing disk space,\n    // and restoring the *.bak db copies next to db_path\n  }\n  r => r?,\n}","preventionTips":["Don't place project dbs inside synced folders (Dropbox/OneDrive)","Ensure clean shutdown; avoid killing the app mid-write","Monitor disk space before large operations","Back up the project db periodically"],"tags":["database","sqlite","corruption","persistence"],"backgroundTag":"database-write-failed","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"}