fix(gui): change app.lock location#310
Open
tristanmsct wants to merge 2 commits intocachebag:masterfrom
Open
Conversation
cachebag
requested changes
Mar 26, 2026
Owner
There was a problem hiding this comment.
@tristanmsct
Thanks for this! Always appreciate someone cleaning up my code lol.
Just make sure you run fmt and clippy and whatnot and amend your changes to your commit. Appreciate the patch!
also, let's add a test. at minimum one that calls acquire_app_lock() and asserts it succeeds, and a second call that asserts it fails with the "already running" error while the first lock is held. the existing tests in the project should give you a feel for the style.
for the commit message, please just write fix(gui): ...
Tries to write app.lock to $XDG_RUNTIME_DIR/nmrs/app.lock Falls back to $XDG_DATA_DIR/nmrs/app.lock
aedd11e to
3eccfef
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.
Hi
I did not find an issue for this small problem so I created a standalone PR
I'm trying to follow the contributing guidelines
This PR is really simple but this file has been bugging me, I'm sorry if I missed anything in terms of formating or type of commit, etc. Let me know if I need to correct anything
Motivation
The app creates a $XDG_DATA_DIR/my_app.lock when running to know if an instance is already running.
I think the name and place of the file can be improved.
The name of the file does not hint at which program creates it.
The file itself would be better placed in the XDG_RUNTIME_DIR within a
nmrssubfolder. Or at least if it stays in $XDG_DATA_DIR, then it can be in annmrssubfolder.Description
This PR simply tries to create the lock file in $XDG_RUNTIME_DIR instead of $XDG_DATA_DIR, and if it fails then it falls back to the old directory.
Also the lock file is now
nmrs/app.lockinstead of justmy_app.lockwhich is clearer for the user.The changes are only in this file
nmrs-gui/src/file_lock.rs.Testing
okexcept 15 tests that wereignored.okI build the app and tested it, the lock file is created at
/run/usr/1000/nmrs/app.lock.I could not get the creation at this specific place to fail, to confirm that it would indeed be created at
~/.local/share/nmrs/app.lockbut I see no reason why it would not work.AI Disclosure
I am not a rust developer and used a LLM to check my syntaxe and be sure to use the right functions for the job.