-
-
Notifications
You must be signed in to change notification settings - Fork 0
v0.15.4: ARCH-1 step 4 — extract MountManager (final ARCH-1 step) #47
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| using System; | ||
| using System.Diagnostics; | ||
| using System.IO; | ||
|
|
||
| namespace Pixelpipe | ||
| { | ||
| // ARCH-1 step 4 (v0.15.4, audit): fourth and final collaborator | ||
| // extracted from the TrayContext partial. Owns just the rclone mount | ||
| // process-lifecycle bits: argument assembly + Process.Start + Job Object | ||
| // binding. The dialog flow (rclone-missing, WinFsp-missing, remote-not- | ||
| // configured, drive-in-use, post-launch result) stays in TrayContext | ||
| // because it's heavily UI-coupled. | ||
| // | ||
| // This is intentionally a thin extraction. The audit calls ARCH-1 | ||
| // incremental; later releases can pull more orchestration in once the | ||
| // shape of "what doesn't need a TrayContext" stabilises. | ||
| internal sealed class MountManager | ||
| { | ||
| // Pure helper, tests cover it. Builds the rclone mount argv that | ||
| // Pixelpipe has used since v0.5.x with all the cache-mode, VFS, | ||
| // network-mode, RC, and bandwidth flags in one place. Caller passes | ||
| // RcCommonFlags + effective bandwidth so this class doesn't need to | ||
| // know about the auth token / per-profile bandwidth resolution. | ||
| internal static string BuildMountArgs(RemoteProfile p, bool fullCache, string rcCommonFlags, string effectiveBandwidth) | ||
| { | ||
| if (p == null) return ""; | ||
| string cacheMode = fullCache ? "full" : "writes"; | ||
| string args = "mount " + TrayContext.QuoteArg(TrayContext.NormalizeRemoteName(p.Remote)) | ||
| + " " + TrayContext.QuoteArg(TrayContext.NormalizeDriveLetter(p.DriveLetter)) | ||
| + " --links" | ||
| + (String.Equals(p.MountMode, "network", StringComparison.OrdinalIgnoreCase) ? " --network-mode" : "") | ||
| + " --vfs-cache-mode " + cacheMode | ||
| + " --dir-cache-time 10m" | ||
| + " --poll-interval 1m" | ||
| + " --vfs-write-back 10s" | ||
| + " --vfs-cache-max-age 6h" | ||
| + " --vfs-cache-max-size 5G" | ||
| + " --volname " + TrayContext.QuoteArg(p.Label) | ||
| + " --rc " + (rcCommonFlags ?? "") | ||
| + " --log-level INFO" | ||
| + " --log-file " + TrayContext.QuoteArg(p.LogFile); | ||
| if (!String.IsNullOrEmpty(effectiveBandwidth) | ||
| && !String.Equals(effectiveBandwidth, "off", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| args += " --bwlimit " + effectiveBandwidth; | ||
| } | ||
| return args; | ||
| } | ||
|
|
||
| // Spawns rclone mount and binds the child to the kill-on-job-close | ||
| // Job Object so it dies with Pixelpipe even on Task Manager kill / | ||
| // crash / sign-out. Returns the started Process; caller is | ||
| // responsible for the post-launch monitor (1900 ms wait + exit | ||
| // check + UI feedback). | ||
| internal static Process StartMountProcess(string rclonePath, string args, Action<string> logJobWarn) | ||
| { | ||
| ProcessStartInfo psi = new ProcessStartInfo(); | ||
| psi.FileName = rclonePath; | ||
| psi.Arguments = args; | ||
| psi.UseShellExecute = false; | ||
| psi.CreateNoWindow = true; | ||
| psi.WindowStyle = ProcessWindowStyle.Hidden; | ||
| psi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
| Process child = Process.Start(psi); | ||
| RcloneJob.TryAssign(child, logJobWarn); | ||
|
Comment on lines
+64
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defensive programming: Process child = Process.Start(psi);
if (child != null)
{
RcloneJob.TryAssign(child, logJobWarn);
} |
||
| return child; | ||
| } | ||
| } | ||
| } | ||
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.
If
p.LogFileis null or empty, passing--log-file ""to rclone can cause it to fail to start on Windows due to an invalid path. It is safer to conditionally append the--log-fileargument only when a valid log file path is provided.