Skip to content

Project recovery tool - #12744

Merged
kryksyh merged 5 commits into
audacity:masterfrom
kryksyh:project-recovery
Dec 2, 2026
Merged

kryksyh merged 5 commits into
audacity:masterfrom
kryksyh:project-recovery

Conversation

@kryksyh

@kryksyh kryksyh commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Resolves: #12414

Adds project recovery tool that allows users to recover a corrupted project. This PR adds the infrastructure, ui and first recovery method which replaces the missing audio data with silence.

  • I signed CLA
  • This PR includes AI assistance
  • If the PR is AI-assisted, I have read, understood and complied with the guidelines for AI-assisted contributions
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

This pull request adds a project recovery module with project inspection, missing-block repair, and a QML recovery wizard. It adds SQLite and binary XML support, project parsing, and WAL-aware working copies. The application can open recovery from the Tools menu or from a project-open error dialog for Audacity exception errors. Tests cover serialization, inspection, and repair.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant ProjectRecoveryDialog
  participant ProjectRecoveryWizardModel
  participant ProjectRecoveryService
  participant ProjectInspector
  participant ProjectRepairer
  User->>ProjectRecoveryDialog: Select project and start analysis
  ProjectRecoveryDialog->>ProjectRecoveryWizardModel: Set path and advance
  ProjectRecoveryWizardModel->>ProjectRecoveryService: Request inspection
  ProjectRecoveryService->>ProjectInspector: Inspect project
  ProjectInspector-->>ProjectRecoveryService: Return inspection
  ProjectRecoveryService-->>ProjectRecoveryWizardModel: Complete inspection future
  ProjectRecoveryWizardModel-->>ProjectRecoveryDialog: Display inspection results
  ProjectRecoveryWizardModel->>ProjectRecoveryService: Request repair
  ProjectRecoveryService->>ProjectRepairer: Repair project copy
  ProjectRepairer-->>ProjectRecoveryService: Return repair report
  ProjectRecoveryService-->>ProjectRecoveryWizardModel: Complete repair future
  ProjectRecoveryDialog->>ProjectRecoveryWizardModel: Open recovered result
Loading
Merge Risk: Low · previous review 76745

The recovery tool works on a copy and leaves the original project untouched. Some edge cases remain: UNC network paths, read-only source projects, concurrent repairs to the same output, and a few unconfirmed UI polish and accessibility items. These are worth fixing but are unlikely to block most users.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "Project recovery tool" names the main change. The PR adds a project recovery module, its UI wizard, and a first recovery method that silences missing audio blocks. The title is short and sp…
Description check Passed The description states the purpose (a tool to recover corrupted projects), links issue #12414, and summarizes the infrastructure, UI, and first recovery method. It also keeps the template checklist. T…
Linked Issues check Passed [#12414] asks for a recovery tool for corrupted projects. The issue has no textual acceptance criteria. Its only detail is a Figma design link, which cannot be checked from the repository. The require…
Out of Scope Changes check Passed Each changed area supports the recovery tool:
- Build changes add the projectrecovery target, the AU_BUILD_PROJECTRECOVERY_TESTS option, and the Audacity.ProjectRecovery QML module.
- `appfactor…
Full details: Title check

Explanation

The title "Project recovery tool" names the main change. The PR adds a project recovery module, its UI wizard, and a first recovery method that silences missing audio blocks. The title is short and specific, though it does not mention the silence-based repair.

Full details: Description check

Explanation

The description states the purpose (a tool to recover corrupted projects), links issue #12414, and summarizes the infrastructure, UI, and first recovery method. It also keeps the template checklist. The template's 'short description' and issue link are present. The first checkbox is ticked and the 'compiles and runs' item is unticked, which is acceptable. It does not explain the recovery method's limits or testing, but the template does not require that, so the description is mostly complete.

Full details: Linked Issues check

Explanation

[#12414] asks for a recovery tool for corrupted projects. The issue has no textual acceptance criteria. Its only detail is a Figma design link, which cannot be checked from the repository. The requirement is therefore to provide a project recovery tool. The whole-PR summary (merge base 9d26524 to head 7674579) shows these implementing changes:

  • Tools menu command PROJECT_RECOVERY_COMMAND (command://project/recovery) opens the recovery wizard (ProjectRecoveryDialog.qml, backed by ProjectRecoveryWizardModel).
  • ProjectInspector::inspect checks the project database, WAL state, and project and autosave documents for missing and orphan blocks.
  • ProjectRepairer::repair and silenceBlocks replace missing audio blocks with silence in a new output file. The original file is not modified.
  • A failed project open offers a Recover action (projectactionscontroller.cpp).
  • Automated tests cover binary XML, document editing, project parsing, inspection, repair, and the service.
    The PR description states the same scope. The summary matches the previous review conclusion. The incremental changes since the previous reviewed head were not read in detail. The verdict relies on the whole-PR summary, which does not contradict the previous conclusion.
Full details: Out of Scope Changes check

Explanation

Each changed area supports the recovery tool:

  • Build changes add the projectrecovery target, the AU_BUILD_PROJECTRECOVERY_TESTS option, and the Audacity.ProjectRecovery QML module.
  • appfactory.cpp, appmenumodel.cpp, the appshell link list, and projectactionscontroller.cpp register the module, the menu command, and the error-dialog entry point.
  • The .cfg theme files add colors for the callout, progress indicator, and track elements used by Callout.qml, IndeterminateProgressBar.qml, and StepIndicator.qml. The existing audio_envelope_point_centre value is unchanged.
  • The wizard model and QML files implement the UI.
  • Binary XML, database, project-document, inspection, repair, working-copy, and command-registration code supports recovery.
  • Tests and test helpers cover the new backend code.
    The verdict relies on the whole-PR summary. Source files were not read directly. The incremental changes since the previous reviewed head were not read in detail. No ignored files apply.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 384a73e6-38df-4ef5-bd13-2e5736f80a52
Commits

Reviewing files that changed from the base of the PR and between 9d26524 and e66ec10.

Files selected for processing: 49

  • CMakeLists.txt
  • src/CMakeLists.txt
  • src/app/CMakeLists.txt
  • src/app/appfactory.cpp
  • src/app/configs/dark.cfg
  • src/app/configs/high_contrast_black.cfg
  • src/app/configs/high_contrast_white.cfg
  • src/app/configs/light.cfg
  • src/appshell/qml/Audacity/AppShell/appmenumodel.cpp
  • src/project/internal/projectactionscontroller.cpp
  • src/projectrecovery/CMakeLists.txt
  • src/projectrecovery/internal/binaryxml.cpp
  • src/projectrecovery/internal/binaryxml.h
  • src/projectrecovery/internal/database.cpp
  • src/projectrecovery/internal/database.h
  • src/projectrecovery/internal/documentedit.cpp
  • src/projectrecovery/internal/documentedit.h
  • src/projectrecovery/internal/projectdocument.cpp
  • src/projectrecovery/internal/projectdocument.h
  • src/projectrecovery/internal/projectinspector.cpp
  • src/projectrecovery/internal/projectinspector.h
  • src/projectrecovery/internal/projectrecoverycommandscontroller.cpp
  • src/projectrecovery/internal/projectrecoverycommandscontroller.h
  • src/projectrecovery/internal/projectrecoverycommandsregister.cpp
  • src/projectrecovery/internal/projectrecoverycommandsregister.h
  • src/projectrecovery/internal/projectrecoverycommandsstate.cpp
  • src/projectrecovery/internal/projectrecoverycommandsstate.h
  • src/projectrecovery/internal/projectrepairer.cpp
  • src/projectrecovery/internal/projectrepairer.h
  • src/projectrecovery/internal/workingcopy.cpp
  • src/projectrecovery/internal/workingcopy.h
  • src/projectrecovery/projectrecoverycommands.h
  • src/projectrecovery/projectrecoverymodule.cpp
  • src/projectrecovery/projectrecoverymodule.h
  • src/projectrecovery/qml/Audacity/ProjectRecovery/CMakeLists.txt
  • src/projectrecovery/qml/Audacity/ProjectRecovery/ProjectRecoveryDialog.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.cpp
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.h
  • src/projectrecovery/qml/Audacity/ProjectRecovery/uicomponents/Callout.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/uicomponents/IndeterminateProgressBar.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/uicomponents/StepIndicator.qml
  • src/projectrecovery/tests/CMakeLists.txt
  • src/projectrecovery/tests/binaryxml_tests.cpp
  • src/projectrecovery/tests/documentedit_tests.cpp
  • src/projectrecovery/tests/projectdocument_tests.cpp
  • src/projectrecovery/tests/projectinspector_tests.cpp
  • src/projectrecovery/tests/projectrepairer_tests.cpp
  • src/projectrecovery/tests/testprojectbuilder.cpp
  • src/projectrecovery/tests/testprojectbuilder.h

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: db838f7f-cf63-4a8a-aa82-68c6cb774054
Commits

Reviewing files that changed from the base of the PR and between e66ec10 and 444bae4.

Files selected for processing: 2

  • src/projectrecovery/qml/Audacity/ProjectRecovery/ProjectRecoveryDialog.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/uicomponents/Callout.qml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd1f072c-45ee-41ea-bcc1-9b7dc53727b5
Commits

Reviewing files that changed from the base of the PR and between 444bae4 and 6b4829e.

Files selected for processing: 9

  • src/projectrecovery/CMakeLists.txt
  • src/projectrecovery/internal/projectinspector.cpp
  • src/projectrecovery/internal/projectinspector.h
  • src/projectrecovery/internal/projectrepairer.cpp
  • src/projectrecovery/internal/workingcopy.cpp
  • src/projectrecovery/internal/workingcopy.h
  • src/projectrecovery/qml/Audacity/ProjectRecovery/ProjectRecoveryDialog.qml
  • src/projectrecovery/tests/CMakeLists.txt
  • src/projectrecovery/tests/projectinspector_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0aaae67c-c764-4abf-b673-af3d87b4dff1
Commits

Reviewing files that changed from the base of the PR and between 6b4829e and 1fc6704.

Files selected for processing: 7

  • src/projectrecovery/internal/projectinspector.cpp
  • src/projectrecovery/internal/workingcopy.cpp
  • src/projectrecovery/qml/Audacity/ProjectRecovery/ProjectRecoveryDialog.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.cpp
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.h
  • src/projectrecovery/qml/Audacity/ProjectRecovery/uicomponents/Callout.qml
  • src/projectrecovery/tests/projectinspector_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 56b05831-fa18-4e7a-9a99-6073d3fa4503
Commits

Reviewing files that changed from the base of the PR and between 1fc6704 and 2a25f56.

Files selected for processing: 2

  • src/projectrecovery/internal/projectinspector.cpp
  • src/projectrecovery/tests/projectinspector_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d7fc2d6d-79dd-4fb8-a271-ee3c2d750452
Commits

Reviewing files that changed from the base of the PR and between 2a25f56 and 302bf55.

Files selected for processing: 9

  • src/projectrecovery/internal/projectinspector.cpp
  • src/projectrecovery/internal/projectinspector.h
  • src/projectrecovery/internal/projectrepairer.cpp
  • src/projectrecovery/internal/workingcopy.cpp
  • src/projectrecovery/internal/workingcopy.h
  • src/projectrecovery/qml/Audacity/ProjectRecovery/ProjectRecoveryDialog.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.cpp
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.h
  • src/projectrecovery/tests/projectinspector_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aca8a8fd-1339-45dd-b550-1fef61690183
Commits

Reviewing files that changed from the base of the PR and between 302bf55 and b16075b.

Files selected for processing: 11

  • src/projectrecovery/CMakeLists.txt
  • src/projectrecovery/internal/projectrecoveryservice.cpp
  • src/projectrecovery/internal/projectrecoveryservice.h
  • src/projectrecovery/iprojectrecoveryservice.h
  • src/projectrecovery/projectrecoverymodule.cpp
  • src/projectrecovery/projectrecoverymodule.h
  • src/projectrecovery/qml/Audacity/ProjectRecovery/ProjectRecoveryDialog.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.cpp
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.h
  • src/projectrecovery/tests/CMakeLists.txt
  • src/projectrecovery/tests/projectrecoveryservice_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d6bd33d-f83e-4bc8-ae94-5bd15d97f9bd
Commits

Reviewing files that changed from the base of the PR and between b16075b and 377cf98.

Files selected for processing: 5

  • src/projectrecovery/internal/binaryxml.cpp
  • src/projectrecovery/internal/workingcopy.cpp
  • src/projectrecovery/qml/Audacity/ProjectRecovery/ProjectRecoveryDialog.qml
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.cpp
  • src/projectrecovery/tests/binaryxml_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31e995b1-0a4e-4967-9521-fc71566ed59f
Commits

Reviewing files that changed from the base of the PR and between 377cf98 and 36d29e1.

Files selected for processing: 4

  • src/projectrecovery/CMakeLists.txt
  • src/projectrecovery/internal/database.cpp
  • src/projectrecovery/tests/CMakeLists.txt
  • src/projectrecovery/tests/testprojectbuilder.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

return error();
}
for (size_t i = 0; i < parameters.size(); ++i) {
bindParameter(statement, static_cast<int>(i + 1), parameters[i]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Data Integrity & Integration · Quick win

Stop execution when parameter binding fails.

bindParameter() discards every binding result. If SQLite rejects a text or blob with SQLITE_TOOBIG, the parameter remains unbound and therefore evaluates to NULL. query() still executes the statement and can report success. (sqlite.org)

The document UPDATE in src/projectrecovery/internal/projectrepairer.cpp, Line 145, uses this path. Subsequent verification protects the original project, but it does not correct the false success returned by query(). (raw.githubusercontent.com)

Return the binding status from bindParameter(). On failure, preserve the error, finalize the statement, and return without calling sqlite3_step().

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d85ef57a-8450-45a3-9fa7-a4f9d40e0730
Commits

Reviewing files that changed from the base of the PR and between 36d29e1 and 7674579.

Files selected for processing: 17

  • src/projectrecovery/internal/binaryxml.cpp
  • src/projectrecovery/internal/database.cpp
  • src/projectrecovery/internal/documentedit.cpp
  • src/projectrecovery/internal/projectinspector.cpp
  • src/projectrecovery/internal/projectrecoverycommandscontroller.cpp
  • src/projectrecovery/internal/projectrecoverycommandsregister.cpp
  • src/projectrecovery/internal/projectrecoverycommandsstate.cpp
  • src/projectrecovery/internal/projectrecoveryservice.cpp
  • src/projectrecovery/internal/projectrepairer.cpp
  • src/projectrecovery/internal/workingcopy.cpp
  • src/projectrecovery/projectrecoverymodule.cpp
  • src/projectrecovery/qml/Audacity/ProjectRecovery/projectrecoverywizardmodel.cpp
  • src/projectrecovery/tests/binaryxml_tests.cpp
  • src/projectrecovery/tests/documentedit_tests.cpp
  • src/projectrecovery/tests/projectinspector_tests.cpp
  • src/projectrecovery/tests/projectrecoveryservice_tests.cpp
  • src/projectrecovery/tests/projectrepairer_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment on lines +110 to +111
document.project = readProjectDocument(decoded.val);
summary.error = document.project ? std::string() : "the document has no project element";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Reject a project root that lacks the required version attributes.

readProjectDocument() accepts a project root without version or audacityversion. The loader rejects that root: HandleXMLTag() returns false when either attribute is missing (au3/libraries/au3-project-file-io/ProjectFileIO.cpp:1826-1837).

The inspector does not flag this case. DocumentNotReadable is set only when no project document parses. A root without the attributes still parses, so the inspector can report a healthy result. The repairer uses the same health check (src/projectrecovery/internal/projectrepairer.cpp:91). The recovered output can then appear healthy even though Audacity cannot open it.

The condition needs a damaged document whose project root lost these attributes. That damage is uncommon, so the impact is narrow.

Suggested fix

     ProjectDocument project;
+    if (!root->attribute("version") || !root->attribute("audacityversion")) {
+        return std::nullopt;
+    }
     project.version = textAttribute(*root, "version");
     project.audacityVersion = textAttribute(*root, "audacityversion");

This check matches the loader's presence test. summarize() then reports "the document has no project element" for this case, which is misleading. Give this case its own error text.


muse::Ret ret = copyToOutput(original, output, workDir);
if (!ret) {
removeOutput(output);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Data Integrity & Integration · Quick win

Do not delete an output that this repair did not create.

Two repair calls can pass the existence checks before either creates output. If one call creates the output and the other then fails in copyToOutput()—including during working-copy preparation—this branch deletes the first call's database and sidecars. The asynchronous service does not serialize repair calls by output path. (raw.githubusercontent.com)

Use per-call staging and publish without replacement. Limit failure cleanup to files owned by that call.

if (copy.walSize() > 0 && !copy.walApplied()) {
return muse::make_ret(muse::Ret::Code::NotSupported, "the -wal file cannot be applied: " + copy.walError());
}
ret = fileSystem()->copy(copy.path(), output);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Make the copied output writable before it is edited.

copyToOutput copies the working copy with fileSystem()->copy. Muse's implementation calls QFile::copy without a permission argument. Qt then keeps the source's read-only bit on the output. If the source project is read-only, the output is read-only too. silenceMissingBlocks then fails to update the document. repair deletes the output and returns an error, so the repair cannot succeed for that project.

Set owner-write permission on output after the copy succeeds and before silenceMissingBlocks runs. Use the permission call that the file system abstraction supports. Do not make the original file writable.

@kryksyh
kryksyh force-pushed the project-recovery branch 3 times, most recently from 2eca148 to db0da29 Compare November 18, 2026 14:25
…ch the block positions

Assisted-by: Claude Code
@kryksyh
kryksyh merged commit a393e0b into audacity:master Dec 2, 2026
3 of 10 checks passed
@kryksyh
kryksyh deleted the project-recovery branch December 2, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement recovery tool for corrupted projects

2 participants