зеркало из https://github.com/microsoft/scalar.git
Mac: Change default location of .gvfsCache folder from /.gvfsCache to ~/.gvfsCache
This commit is contained in:
Родитель
c9e404d59f
Коммит
085ac57a9b
|
@ -16,7 +16,9 @@ namespace GVFS.Common
|
|||
|
||||
public const string GVFSEtwProviderName = "Microsoft.Git.GVFS";
|
||||
public const string WorkingDirectoryRootName = "src";
|
||||
public const string UnattendedEnvironmentVariable = "GVFS_UNATTENDED";
|
||||
public const string UnattendedEnvironmentVariable = "GVFS_UNATTENDED";
|
||||
|
||||
public const string DefaultGVFSCacheFolderName = ".gvfsCache";
|
||||
|
||||
public const string GitIsNotInstalledError = "Could not find git.exe. Ensure that Git is installed.";
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace GVFS.Common
|
|||
public abstract bool TryKillProcessTree(int processId, out int exitCode, out string error);
|
||||
|
||||
public abstract bool TryGetGVFSEnlistmentRoot(string directory, out string enlistmentRoot, out string errorMessage);
|
||||
public abstract bool TryGetDefaultLocalCacheRoot(string enlistmentRoot, out string localCacheRoot, out string localCacheRootError);
|
||||
|
||||
public abstract bool IsGitStatusCacheSupported();
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@ namespace GVFS.Common
|
|||
{
|
||||
public class LocalCacheResolver
|
||||
{
|
||||
public const string DefaultGVFSCacheFolderName = ".gvfsCache";
|
||||
|
||||
private const string EtwArea = nameof(LocalCacheResolver);
|
||||
private const string MappingFile = "mapping.dat";
|
||||
private const string MappingVersionKey = "GVFS_LocalCache_MappingVersion";
|
||||
|
@ -26,20 +24,16 @@ namespace GVFS.Common
|
|||
this.enlistment = enlistment;
|
||||
}
|
||||
|
||||
public static string GetDefaultLocalCacheRoot(GVFSEnlistment enlistment)
|
||||
public static bool TryGetDefaultLocalCacheRoot(GVFSEnlistment enlistment, out string localCacheRoot, out string localCacheRootError)
|
||||
{
|
||||
string localCacheRoot;
|
||||
if (GVFSEnlistment.IsUnattended(tracer: null))
|
||||
{
|
||||
localCacheRoot = Path.Combine(enlistment.DotGVFSRoot, DefaultGVFSCacheFolderName);
|
||||
}
|
||||
else
|
||||
{
|
||||
string pathRoot = Path.GetPathRoot(enlistment.EnlistmentRoot);
|
||||
localCacheRoot = Path.Combine(pathRoot, DefaultGVFSCacheFolderName);
|
||||
localCacheRoot = Path.Combine(enlistment.DotGVFSRoot, GVFSConstants.DefaultGVFSCacheFolderName);
|
||||
localCacheRootError = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
return localCacheRoot;
|
||||
return GVFSPlatform.Instance.TryGetDefaultLocalCacheRoot(enlistment.EnlistmentRoot, out localCacheRoot, out localCacheRootError);
|
||||
}
|
||||
|
||||
public bool TryGetLocalCacheKeyFromLocalConfigOrRemoteCacheServers(
|
||||
|
|
|
@ -124,6 +124,30 @@ namespace GVFS.Platform.POSIX
|
|||
return POSIXPlatform.TryGetGVFSEnlistmentRootImplementation(directory, out enlistmentRoot, out errorMessage);
|
||||
}
|
||||
|
||||
public override bool TryGetDefaultLocalCacheRoot(string enlistmentRoot, out string localCacheRoot, out string localCacheRootError)
|
||||
{
|
||||
string homeDirectory = Environment.GetEnvironmentVariable("HOME");
|
||||
if (string.IsNullOrEmpty(homeDirectory))
|
||||
{
|
||||
localCacheRoot = null;
|
||||
localCacheRootError = "Failed to read HOME environment variable";
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
localCacheRoot = Path.Combine(homeDirectory, GVFSConstants.DefaultGVFSCacheFolderName);
|
||||
localCacheRootError = null;
|
||||
return true;
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
localCacheRoot = null;
|
||||
localCacheRootError = $"Failed to build local cache path using HOME: {e.Message}";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsGitStatusCacheSupported()
|
||||
{
|
||||
// TODO(POSIX): support git status cache
|
||||
|
|
|
@ -325,6 +325,14 @@ namespace GVFS.Platform.Windows
|
|||
return WindowsPlatform.TryGetGVFSEnlistmentRootImplementation(directory, out enlistmentRoot, out errorMessage);
|
||||
}
|
||||
|
||||
public override bool TryGetDefaultLocalCacheRoot(string enlistmentRoot, out string localCacheRoot, out string localCacheRootError)
|
||||
{
|
||||
string pathRoot = Path.GetPathRoot(enlistmentRoot);
|
||||
localCacheRoot = Path.Combine(pathRoot, GVFSConstants.DefaultGVFSCacheFolderName);
|
||||
localCacheRootError = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TryKillProcessTree(int processId, out int exitCode, out string error)
|
||||
{
|
||||
ProcessResult result = ProcessHelper.Run("taskkill", $"/pid {processId} /f /t");
|
||||
|
|
|
@ -103,6 +103,11 @@ namespace GVFS.UnitTests.Mock.Common
|
|||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool TryGetDefaultLocalCacheRoot(string enlistmentRoot, out string localCacheRoot, out string localCacheRootError)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void StartBackgroundProcess(ITracer tracer, string programName, string[] args)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace GVFS.CommandLine
|
|||
[Option(
|
||||
"local-cache-path",
|
||||
Required = false,
|
||||
HelpText = "Use this option to override the path for the local GVFS cache. The default location is the .gvfsCache folder in the root of the volume.")]
|
||||
HelpText = VerbConstants.CloneVerb.LocalCacheRootHelpText)]
|
||||
public string LocalCacheRoot { get; set; }
|
||||
|
||||
protected override string VerbName
|
||||
|
@ -152,7 +152,13 @@ namespace GVFS.CommandLine
|
|||
string resolvedLocalCacheRoot;
|
||||
if (string.IsNullOrWhiteSpace(this.LocalCacheRoot))
|
||||
{
|
||||
resolvedLocalCacheRoot = LocalCacheResolver.GetDefaultLocalCacheRoot(enlistment);
|
||||
string localCacheRootError;
|
||||
if (!LocalCacheResolver.TryGetDefaultLocalCacheRoot(enlistment, out resolvedLocalCacheRoot, out localCacheRootError))
|
||||
{
|
||||
this.ReportErrorAndExit(
|
||||
tracer,
|
||||
$"Failed to determine the default location for the local GVFS cache: `{localCacheRootError}`");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -302,7 +302,7 @@ namespace GVFS.CommandLine
|
|||
{
|
||||
try
|
||||
{
|
||||
string localCacheArchivePath = Path.Combine(archiveFolderPath, LocalCacheResolver.DefaultGVFSCacheFolderName);
|
||||
string localCacheArchivePath = Path.Combine(archiveFolderPath, GVFSConstants.DefaultGVFSCacheFolderName);
|
||||
Directory.CreateDirectory(localCacheArchivePath);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(localCacheRoot))
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
namespace GVFS.CommandLine
|
||||
{
|
||||
public static class VerbConstants
|
||||
{
|
||||
public static class CloneVerb
|
||||
{
|
||||
public const string LocalCacheRootHelpText = "Use this option to override the path for the local GVFS cache. The default location is ~/.gvfsCache";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
namespace GVFS.CommandLine
|
||||
{
|
||||
public static class VerbConstants
|
||||
{
|
||||
public static class CloneVerb
|
||||
{
|
||||
public const string LocalCacheRootHelpText = "Use this option to override the path for the local GVFS cache. The default location is the .gvfsCache folder in the root of the volume.";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,9 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="CommandLine\VerbConstants.Windows.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GVFS.Platform.Mac\GVFS.Platform.Mac.csproj" />
|
||||
<ProjectReference Include="..\GVFS.Virtualization\GVFS.Virtualization.csproj" />
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
<Compile Include="CommandLine\MountVerb.cs" />
|
||||
<Compile Include="CommandLine\PrefetchVerb.cs" />
|
||||
<Compile Include="CommandLine\UpgradeVerb.cs" />
|
||||
<Compile Include="CommandLine\VerbConstants.Windows.cs" />
|
||||
<Compile Include="RepairJobs\BackgroundOperationDatabaseRepairJob.cs" />
|
||||
<Compile Include="RepairJobs\BlobSizeDatabaseRepairJob.cs" />
|
||||
<Compile Include="RepairJobs\GitHeadRepairJob.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче