-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add file locking and improved chmod handling #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @iHildy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the stability and reliability of the synchronization process. It introduces a robust file-based locking system to prevent concurrent operations from interfering with each other, and refines file permission handling to gracefully manage non-existent paths, thereby improving overall system resilience. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a robust file-based locking mechanism to prevent concurrent sync operations and a chmodIfExists utility for safer file permission changes. The changes are well-structured, with new logic for locking and its tests in dedicated files. The core sync service is cleanly refactored to adopt this locking, using wrapper functions to separate concerns. The new chmodIfExists function is also a good addition for robustness.
I've made a couple of suggestions for minor improvements:
- In
src/sync/lock.ts, there's a piece of unreachable code that can be removed. - In
src/sync/service.ts, there's an opportunity to simplify the code by removing some redundantasync/awaitkeywords when wrapping service methods with the new locking functions.
Summary
Introduce a file-based sync lock to coordinate concurrent sync operations and a safe chmod helper to gracefully handle missing files. Refactors across apply, config, and service to adopt the new utilities. Added tests for new features.
Changes
src/sync/config.tsand use it inwriteJsonFile, replacing directfs.chmodcalls; export/import adjusted; tests extend to cover behavior.src/sync/apply.ts:copyFileWithModeandcopyDirRecursiveapplyExtraSecretssrc/sync/lock.tswithtryAcquireSyncLock,withSyncLock, and related logicsrc/sync/lock.test.tscovering acquisition, busy state, and stale lock handlingsrc/sync/service.ts:runExclusive,skipIfBusy)startupSync,init,link,pull,push,enableSecrets,resolve) with lockingchmodIfExistsinsrc/sync/config.test.tschmodIfExistsexportTesting
bun test(ormise run testper project setup)chmodIfExistsignores missing paths without errorNext steps (if you want): I can run the test suite, report results, and adjust any failing tests.