Feat/add option to change virtual drive path#345
Draft
egalvis27 wants to merge 3 commits into
Draft
Conversation
|
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.



What is Changed / Added
Virtual Drive Root Path Selection
This PR introduces the ability for users to choose where the Internxt virtual drive is mounted on their system.
How it works
The user selects a base directory (e.g.
~/Downloads). The app always creates a fixed subfolder calledInternxt Driveinside it, so the final mount point is always<base>/Internxt Drive/. This separation ensures the FUSE filesystem is isolated and never conflicts with the user's own files in the chosen folder.The selected base path is persisted in the config store under
virtualDriveRoot. The legacysyncRootkey is kept in sync for backwards compatibility with older code paths that still read it.Remount lifecycle
Changing the root path triggers a full remount cycle orchestrated by
remountVirtualDriveOnRootChange:Stop — The running FUSE daemon receives
SIGTERM. The Go process callsserver.Unmount()to detach the filesystem from the kernel. If that fails (e.g. the file manager has the folder open), the daemon still exits.Stale mount cleanup — Before deleting the old directory,
fusermount3 -uz <oldPath>is issued as a lazy unmount. This forces the kernel to release the mount entry even if the daemon exited without cleanly unmounting, preventingENOTCONNerrors on subsequent filesystem operations.Old directory removal — The previous
Internxt Drivefolder is deleted. Several safety guards prevent accidental deletion: the path must be non-empty, must not resolve to/, and must not resolve to the user's home directory.Start — A new FUSE daemon is spawned with the updated
INTERNXT_MOUNTenvironment variable pointing to the new path. The folder is created automatically if it does not exist.Boot ID correlation
Each daemon spawn generates a random
bootId(UUID). It is passed to the Go process viaINTERNXT_BOOT_IDand echoed back in thePOST /daemon/readyHTTP payload. The Node.js side validates that the received boot ID matches the active one before resolving the startup promise. This prevents a stale ready signal from a slow-exiting previous daemon from being mistaken for the new daemon being ready.Concurrency guards
Both
stopVirtualDriveOnceandremountVirtualDriveOnRootChangededuplicate concurrent calls via an in-flight promise. If a remount is already in progress when a second call arrives (e.g. the user clicks "Change" twice), the second caller awaits the same promise rather than starting a parallel remount. The in-flight reference is cleared in afinallyblock so subsequent calls can proceed normally after completion or failure.