refactor: create project filesystem architecture#2525
Open
Conversation
Contributor
|
Container images for this PR have been built successfully!
Built from commit 23d007b |
eef3982 to
a4438b1
Compare
a1f12e0 to
ddfb994
Compare
ddfb994 to
23d007b
Compare
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.

Checklist
mainbranchWhat This PR Implements
Fixes:
Changes Made
Testing Done
./scripts/development/dev.sh startjust lint all)just test backendAI Tool Used (if applicable)
AI Tool:
Assistance Level:
What AI helped with:
I reviewed and edited all AI-generated output:
I ran all required tests and manually verified changes:
Additional Context
Disclaimer Greptiles Reviews use AI, make sure to check over its work.
To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike
To have Greptile Re-Review the changes, mention
greptileai.Greptile Summary
This PR introduces a
ProjectFilesystemabstraction (backend/pkg/projects/filesystem.go) that centralises all project directory operations behind a staging/promotion model, replacing scatteredos.Rename,os.RemoveAll, and directWriteProjectFilescalls spread acrossproject_service.go. It also adds filesystem rollback when a DB save fails after promotion, and fixes the0700staging-directory permission bug by immediatelychmoding to0755.ProjectFilesystemtype withStageCreate,StageUpdate,StageGitSync, andPromote, including atomic backup-and-restore on promotion failure.preparePromotedProjectRollbackInternalinproject_service.gosnapshots the live directory beforePromoteso the filesystem can be restored if the subsequentdb.Savecall fails — covering bothUpdateProject(including rename) andApplyGitSyncProjectFiles.addWatchInternalinfswatch/watcher.goextends symlink-aware watching by also adding the resolved real target whenfollowSymlinksis enabled, with rollback if the primary watch add fails.Confidence Score: 5/5
Safe to merge — the refactoring is well-structured, the staging/promotion model is correct, and integration tests cover the key rollback paths for both rename and git-sync scenarios.
The core logic (staging, promotion, backup/restore) is implemented correctly and covered by new integration tests. No functional defects were found in the changed paths. Style nits around the Internal suffix convention are the only findings.
No files require special attention beyond the minor naming nits in project_service.go and filesystem_test.go.
Comments Outside Diff (1)
backend/pkg/projects/filesystem.go, line 1316-1327 (link)If
os.Rename(stagePath, targetLivePath)fails and the subsequent restoreos.Rename(backupPath, currentLivePath)also fails, the function returns immediately without cleaning up eitherbackupPathorstagePath. Both hidden directories (.arcane-project-backup-*and the stage dir) are abandoned under the projects root. Repeated failures would accumulate orphaned directories. Consider adding a best-effort_ = os.RemoveAll(stagePath)inside the restore-failure branch before returning.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (6): Last reviewed commit: "refactor: create project filesystem arch..." | Re-trigger Greptile
Context used: