Repository navigation
fix(project): keep a copy of an unreadable project config before defaults replace it - #4420
Draft
richiemcilroy wants to merge 2 commits into
Draft
richiemcilroy wants to merge 2 commits into
richiemcilroy wants to merge 2 commits into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Member
Author
|
@greptileai review |
… an existing path
Member
Author
|
@greptileai review |
Comment on lines
+3896
to
+3898
| staged | ||
| .persist_noclobber(&backup) | ||
| .map_err(|error| error.error)?; |
Contributor
There was a problem hiding this comment.
Backups fail on exFAT. On macOS exFAT drives and some network volumes,
persist_noclobber fails with ENOTSUP. The export code already handles this case in persist_without_replacing. Here, the error only produces a log warning and the temporary copy is dropped. Callers still use defaults and save over the original, leaving no recovery copy. The previous plain rename worked on these drives.
Add a safe fallback for filesystems that cannot support persist_noclobber, while keeping the protection against existing files and symlinks.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/project/src/configuration.rs
Line: 3896-3898
Comment:
**Backups fail on exFAT.** On macOS exFAT drives and some network volumes, `persist_noclobber` fails with `ENOTSUP`. The export code already handles this case in `persist_without_replacing`. Here, the error only produces a log warning and the temporary copy is dropped. Callers still use defaults and save over the original, leaving no recovery copy. The previous plain rename worked on these drives.
Add a safe fallback for filesystems that cannot support `persist_noclobber`, while keeping the protection against existing files and symlinks.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
project-config.jsonexists but can't be read, every caller falls back to a default configuration, and the next save writes that default over the file. All zooms, captions, text, clips and cuts in it are gone, with no warning.flowchart LR A[project-config.json<br/>written by a newer Cap,<br/>or edited by hand] -->|serde / validate error| B[ProjectConfiguration::load<br/>InvalidData] B --> C[RecordingMeta::project_config<br/>returns default] B --> D[load#40;#41;.unwrap_or_default#40;#41;<br/>clips, screenshot editor, overlay] C --> E[editor builds a timeline<br/>project.write] D --> F[next edit<br/>project.write] E --> G[original edits lost] F --> GRecordingMeta::project_config(crates/project/src/meta.rs:303) maps every non-NotFounderror toProjectConfiguration::default(). The editor then sees no timeline and saves one (crates/editor/src/editor_instance.rs).load().unwrap_or_default()then write pattern ineditor_clips.rs(append clip),screenshot_editor.rsandrecordings_overlay.rs.loadfails on any enum value this build doesn't know. None of the configuration enums has a fallback variant. It also fails whenvalidate()rejects an annotation. A project opened in an older build after a newer one saved it is enough.Fix
ProjectConfiguration::loadkeeps a copy of the file before returning the parse or validation error:project-config.json.unreadable-<hash of contents>, written to a temp file and renamed into place. Loading the same unreadable file again doesn't add copies. A different unreadable version gets its own.project-config.json, then a default is savedproject-config.json.unreadable-<hash>Add a safe fallback for exFAT backup writes before merging.
Findings
Fix with agent prompt
Summary
The PR keeps recovery copies of unreadable project settings before callers replace them with defaults.
Reviews (2) · Last reviewed commit: "fix(project): keep non-UTF-8 configs and..." · Reviewed by Greptile