in GVFS/GVFS/CommandLine/ServiceVerb.cs [43:136]
public override void Execute()
{
int optionCount = new[] { this.MountAll, this.UnmountAll, this.List }.Count(flag => flag);
if (optionCount == 0)
{
this.ReportErrorAndExit($"Error: You must specify an argument. Run 'gvfs {ServiceVerbName} --help' for details.");
}
else if (optionCount > 1)
{
this.ReportErrorAndExit($"Error: You cannot specify multiple arguments. Run 'gvfs {ServiceVerbName} --help' for details.");
}
string errorMessage;
List<string> repoList;
if (!this.TryGetRepoList(out repoList, out errorMessage))
{
this.ReportErrorAndExit("Error getting repo list: " + errorMessage);
}
if (this.List)
{
foreach (string repoRoot in repoList)
{
if (this.IsRepoMounted(repoRoot))
{
this.Output.WriteLine(repoRoot);
}
}
}
else if (this.MountAll)
{
// Always ask the service to ensure that PrjFlt is enabled. This will ensure that the GVFS installer properly waits for
// GVFS.Service to finish enabling PrjFlt's AutoLogger
string error;
if (!this.TryEnableAndAttachPrjFltThroughService(string.Empty, out error))
{
this.ReportErrorAndExit(tracer: null, exitCode: ReturnCode.FilterError, error: $"Failed to enable PrjFlt: {error}");
}
List<string> failedRepoRoots = new List<string>();
foreach (string repoRoot in repoList)
{
if (!this.IsRepoMounted(repoRoot))
{
this.Output.WriteLine("\r\nMounting repo at " + repoRoot);
ReturnCode result = this.Execute<MountVerb>(repoRoot);
if (result != ReturnCode.Success)
{
failedRepoRoots.Add(repoRoot);
}
}
}
if (failedRepoRoots.Count() > 0)
{
string errorString = $"The following repos failed to mount:{Environment.NewLine}{string.Join("\r\n", failedRepoRoots.ToArray())}";
Console.Error.WriteLine(errorString);
this.ReportErrorAndExit(Environment.NewLine + errorString);
}
}
else if (this.UnmountAll)
{
List<string> failedRepoRoots = new List<string>();
foreach (string repoRoot in repoList)
{
if (this.IsRepoMounted(repoRoot))
{
this.Output.WriteLine("\r\nUnmounting repo at " + repoRoot);
ReturnCode result = this.Execute<UnmountVerb>(
repoRoot,
verb =>
{
verb.SkipUnregister = true;
verb.SkipLock = true;
});
if (result != ReturnCode.Success)
{
failedRepoRoots.Add(repoRoot);
}
}
}
if (failedRepoRoots.Count() > 0)
{
string errorString = $"The following repos failed to unmount:{Environment.NewLine}{string.Join(Environment.NewLine, failedRepoRoots.ToArray())}";
Console.Error.WriteLine(errorString);
this.ReportErrorAndExit(Environment.NewLine + errorString);
}
}
}