Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions GVFS/GVFS.Common/GVFSPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public GVFSPlatform(UnderConstructionFlags underConstruction)
public UnderConstructionFlags UnderConstruction { get; }
public abstract string Name { get; }

public abstract string GVFSConfigPath { get; }

public static void Register(GVFSPlatform platform)
{
if (GVFSPlatform.Instance != null)
Expand Down Expand Up @@ -70,6 +72,20 @@ public static void Register(GVFSPlatform platform)
public abstract bool IsElevated();
public abstract string GetCurrentUser();
public abstract string GetUserIdFromLoginSessionId(int sessionId, ITracer tracer);

/// <summary>
/// Get the directory for upgrades that is permissioned to
/// require elevated privledes to modify. This can be used for
/// data that we don't want normal user accounts to modify.
/// </summary>
public abstract string GetUpgradeProtectedDataDirectory();

/// <summary>
/// Get the directory for upgrades that is permissioned for
/// user accounts to have access to.
/// </summary>
public abstract string GetUpgradeNonProtectedDataDirectory();

public abstract void ConfigureVisualStudio(string gitBinPath, ITracer tracer);

public abstract bool TryGetGVFSHooksPathAndVersion(out string hooksPaths, out string hooksVersion, out string error);
Expand Down Expand Up @@ -117,6 +133,7 @@ public abstract class GVFSPlatformConstants
public static readonly char PathSeparator = Path.DirectorySeparatorChar;
public abstract string ExecutableExtension { get; }
public abstract string InstallerExtension { get; }
public abstract bool SupportsInlineUpgrade { get; }
public abstract string WorkingDirectoryBackingRootPath { get; }
public abstract string DotGVFSRoot { get; }

Expand Down
2 changes: 1 addition & 1 deletion GVFS/GVFS.Common/GitHubUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public GitHubUpgrader(
{
this.Config = upgraderConfig;

string upgradesDirectoryPath = ProductUpgraderInfo.GetUpgradesDirectoryPath();
string upgradesDirectoryPath = ProductUpgraderInfo.GetUpgradeBasicDataDirectory();
this.fileSystem.CreateDirectory(upgradesDirectoryPath);
}

Expand Down
5 changes: 1 addition & 4 deletions GVFS/GVFS.Common/LocalGVFSConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public class LocalGVFSConfig

public LocalGVFSConfig()
{
string servicePath = GVFSPlatform.Instance.GetDataRootForGVFSComponent(GVFSConstants.Service.ServiceName);
string gvfsDirectory = Path.GetDirectoryName(servicePath);

this.configFile = Path.Combine(gvfsDirectory, FileName);
this.configFile = GVFSPlatform.Instance.GVFSConfigPath;
this.fileSystem = new PhysicalFileSystem();
}

Expand Down
4 changes: 1 addition & 3 deletions GVFS/GVFS.Common/ProductUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace GVFS.Common

public abstract class ProductUpgrader : IDisposable
{
public const string ToolsDirectory = "Tools";
protected readonly Version installedVersion;
protected readonly ITracer tracer;
protected readonly PhysicalFileSystem fileSystem;
Expand Down Expand Up @@ -170,8 +169,7 @@ public static bool TryCreateUpgrader(

public virtual bool TrySetupToolsDirectory(out string upgraderToolPath, out string error)
{
string rootDirectoryPath = ProductUpgraderInfo.GetUpgradesDirectoryPath();
string toolsDirectoryPath = Path.Combine(rootDirectoryPath, ToolsDirectory);
string toolsDirectoryPath = ProductUpgraderInfo.GetUpgradeApplicationDirectory();

if (!this.productUpgraderPlatformStrategy.TryPrepareApplicationDirectory(out error))
{
Expand Down
1 change: 1 addition & 0 deletions GVFS/GVFS.Common/ProductUpgraderInfo.Shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public partial class ProductUpgraderInfo
public const string UpgradeDirectoryName = "GVFS.Upgrade";
public const string LogDirectory = "UpgraderLogs";
public const string DownloadDirectory = "Downloads";
public const string ToolsDirectory = "Tools";
public const string HighestAvailableVersionFileName = "HighestAvailableVersion";

public static bool IsLocalUpgradeAvailable(ITracer tracer, string gvfsDataRoot)
Expand Down
22 changes: 16 additions & 6 deletions GVFS/GVFS.Common/ProductUpgraderInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@ public static string CurrentGVFSVersion()
return ProcessHelper.GetCurrentProcessVersion();
}

public static string GetUpgradesDirectoryPath()
{
return GVFSPlatform.Instance.GetDataRootForGVFSComponent(UpgradeDirectoryName);
public static string GetUpgradeApplicationDirectory()
{
return Path.Combine(GVFSPlatform.Instance.GetUpgradeProtectedDataDirectory(), ToolsDirectory);
}

public static string GetUpgradeProtectedDataDirectory()
{
return GVFSPlatform.Instance.GetUpgradeProtectedDataDirectory();
}

public static string GetUpgradeBasicDataDirectory()
{
return GVFSPlatform.Instance.GetUpgradeNonProtectedDataDirectory();
}

public static string GetLogDirectoryPath()
{
return Path.Combine(GetUpgradesDirectoryPath(), LogDirectory);
return Path.Combine(GetUpgradeBasicDataDirectory(), LogDirectory);
}

public static string GetAssetDownloadsPath()
{
return Path.Combine(GetUpgradesDirectoryPath(), DownloadDirectory);
return Path.Combine(GetUpgradeProtectedDataDirectory(), ProductUpgraderInfo.DownloadDirectory);
}

public void DeleteAllInstallerDownloads()
Expand All @@ -53,7 +63,7 @@ public void DeleteAllInstallerDownloads()

public void RecordHighestAvailableVersion(Version highestAvailableVersion)
{
string highestAvailableVersionFile = GetHighestAvailableVersionFilePath(GetUpgradesDirectoryPath());
string highestAvailableVersionFile = GetHighestAvailableVersionFilePath(GetUpgradeBasicDataDirectory());

if (highestAvailableVersion == null)
{
Expand Down
26 changes: 25 additions & 1 deletion GVFS/GVFS.Platform.Mac/MacPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ namespace GVFS.Platform.Mac
{
public partial class MacPlatform : POSIXPlatform
{
public MacPlatform()
private const string UpgradeProtectedDataDirectory = "/usr/local/vfsforgit_upgrader";

public MacPlatform() : base(
underConstruction: new UnderConstructionFlags(
supportsGVFSUpgrade: true,
supportsGVFSConfig: true,
supportsNuGetEncryption: false))
{
}

Expand All @@ -24,6 +30,14 @@ public MacPlatform()
public override GVFSPlatformConstants Constants { get; } = new MacPlatformConstants();
public override IPlatformFileSystem FileSystem { get; } = new MacFileSystem();

public override string GVFSConfigPath
{
get
{
return Path.Combine(this.Constants.GVFSBinDirectoryPath, LocalGVFSConfig.FileName);
}
}

public override string GetOSVersionInformation()
{
ProcessResult result = ProcessHelper.Run("sw_vers", args: string.Empty, redirectOutput: true);
Expand Down Expand Up @@ -57,6 +71,16 @@ public override FileBasedLock CreateFileBasedLock(
{
return new MacFileBasedLock(fileSystem, tracer, lockPath);
}

public override string GetUpgradeProtectedDataDirectory()
{
return UpgradeProtectedDataDirectory;
}

public override string GetUpgradeNonProtectedDataDirectory()
{
return this.GetDataRootForGVFSComponent(ProductUpgraderInfo.UpgradeDirectoryName);
}

public override Dictionary<string, string> GetPhysicalDiskInfo(string path, bool sizeStatsOnly)
{
Expand Down
3 changes: 1 addition & 2 deletions GVFS/GVFS.Platform.Mac/MacProductUpgraderPlatformStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public override bool TryPrepareLogDirectory(out string error)

public override bool TryPrepareApplicationDirectory(out string error)
{
string rootDirectoryPath = ProductUpgraderInfo.GetUpgradesDirectoryPath();
string toolsDirectoryPath = Path.Combine(rootDirectoryPath, ProductUpgrader.ToolsDirectory);
string toolsDirectoryPath = ProductUpgraderInfo.GetUpgradeApplicationDirectory();

Exception deleteDirectoryException;
if (this.FileSystem.DirectoryExists(toolsDirectoryPath) &&
Expand Down
2 changes: 1 addition & 1 deletion GVFS/GVFS.Platform.Mac/ProjFSKext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public string LogsFolderPath

public bool IsGVFSUpgradeSupported()
{
return false;
return true;
}

public bool IsSupported(string normalizedEnlistmentRootPath, out string warning, out string error)
Expand Down
2 changes: 2 additions & 0 deletions GVFS/GVFS.Platform.POSIX/POSIXPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ public override HashSet<string> UpgradeBlockingProcesses
{
get { return new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "GVFS.Mount", "git", "wish" }; }
}

public override bool SupportsInlineUpgrade { get; } = true;
}
}
}
2 changes: 1 addition & 1 deletion GVFS/GVFS.Platform.Windows/GVFS.Platform.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
25 changes: 24 additions & 1 deletion GVFS/GVFS.Platform.Windows/WindowsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public partial class WindowsPlatform : GVFSPlatform
public override string Name { get => "Windows"; }
public override GVFSPlatformConstants Constants { get; } = new WindowsPlatformConstants();

public override string GVFSConfigPath
{
get
{
string servicePath = GVFSPlatform.Instance.GetDataRootForGVFSComponent(GVFSConstants.Service.ServiceName);
string gvfsDirectory = Path.GetDirectoryName(servicePath);

return Path.Combine(gvfsDirectory, LocalGVFSConfig.FileName);
}
}

public static string GetStringFromRegistry(string key, string valueName)
{
object value = GetValueFromRegistry(RegistryHive.LocalMachine, key, valueName);
Expand Down Expand Up @@ -326,6 +337,16 @@ public override string GetUserIdFromLoginSessionId(int sessionId, ITracer tracer
}
}

public override string GetUpgradeProtectedDataDirectory()
{
return this.GetDataRootForGVFSComponent(ProductUpgraderInfo.UpgradeDirectoryName);
}

public override string GetUpgradeNonProtectedDataDirectory()
{
return this.GetDataRootForGVFSComponent(ProductUpgraderInfo.UpgradeDirectoryName);
}

public override Dictionary<string, string> GetPhysicalDiskInfo(string path, bool sizeStatsOnly) => WindowsPhysicalDiskInfo.GetPhysicalDiskInfo(path, sizeStatsOnly);

public override bool IsConsoleOutputRedirectedToFile()
Expand Down Expand Up @@ -422,7 +443,9 @@ public override string InstallerExtension
{
get { return ".exe"; }
}


public override bool SupportsInlineUpgrade { get; } = false;

public override string WorkingDirectoryBackingRootPath
{
get { return GVFSConstants.WorkingDirectoryRootName; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public override bool TryPrepareLogDirectory(out string error)

public override bool TryPrepareApplicationDirectory(out string error)
{
string rootDirectoryPath = ProductUpgraderInfo.GetUpgradesDirectoryPath();
string toolsDirectoryPath = Path.Combine(rootDirectoryPath, ProductUpgrader.ToolsDirectory);
string toolsDirectoryPath = ProductUpgraderInfo.GetUpgradeApplicationDirectory();

Exception deleteDirectoryException;
if (this.FileSystem.DirectoryExists(toolsDirectoryPath) &&
Expand Down
1 change: 1 addition & 0 deletions GVFS/GVFS.Service/GVFS.Service.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Compile Include="IRepoMounter.cs" />
<Compile Include="IRepoRegistry.cs" />
<Compile Include="Program.Mac.cs" />
<Compile Include="ProductUpgradeTimer.cs" />
<Compile Include="RepoRegistration.cs" />
<Compile Include="RepoRegistry.cs" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions GVFS/GVFS.Service/GVFSService.Mac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class GVFSService
private string serviceName;
private IRepoRegistry repoRegistry;
private RequestHandler requestHandler;
private ProductUpgradeTimer productUpgradeTimer;

public GVFSService(
ITracer tracer,
Expand All @@ -32,6 +33,7 @@ public GVFSService(
this.serviceStopped = new ManualResetEvent(false);
this.serviceThread = new Thread(this.ServiceThreadMain);
this.requestHandler = new RequestHandler(this.tracer, EtwArea, this.repoRegistry);
this.productUpgradeTimer = new ProductUpgradeTimer(tracer);
}

public void Run()
Expand All @@ -51,6 +53,7 @@ public void Run()
this.requestHandler.HandleRequest))
{
this.serviceThread.Start();
this.productUpgradeTimer.Start();
this.serviceThread.Join();
}
}
Expand Down
2 changes: 1 addition & 1 deletion GVFS/GVFS.Service/GVFSService.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private void CreateAndConfigureProgramDataDirectories()
// Create GVFS.Service and GVFS.Upgrade related directories (if they don't already exist)
Directory.CreateDirectory(serviceDataRootPath, serviceDataRootSecurity);
Directory.CreateDirectory(this.serviceDataLocation, serviceDataRootSecurity);
Directory.CreateDirectory(ProductUpgraderInfo.GetUpgradesDirectoryPath(), serviceDataRootSecurity);
Directory.CreateDirectory(ProductUpgraderInfo.GetUpgradeProtectedDataDirectory(), serviceDataRootSecurity);

// Ensure the ACLs are set correctly on any files or directories that were already created (e.g. after upgrading VFS4G)
Directory.SetAccessControl(serviceDataRootPath, serviceDataRootSecurity);
Expand Down
4 changes: 2 additions & 2 deletions GVFS/GVFS.Service/ProductUpgradeTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace GVFS.Service
public class ProductUpgradeTimer : IDisposable
{
private static readonly TimeSpan TimeInterval = TimeSpan.FromDays(1);
private JsonTracer tracer;
private ITracer tracer;
private PhysicalFileSystem fileSystem;
private Timer timer;

public ProductUpgradeTimer(JsonTracer tracer)
public ProductUpgradeTimer(ITracer tracer)
{
this.tracer = tracer;
this.fileSystem = new PhysicalFileSystem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override int ExitCode
get { return this.exitCode; }
}

public override bool TryStart(string path, string args, out Exception exception)
public override bool TryStart(string path, string args, bool useShellExecute, out Exception exception)
{
this.LaunchPath = path;
this.IsLaunched = true;
Expand Down
4 changes: 3 additions & 1 deletion GVFS/GVFS.UnitTests/Common/ProductUpgraderInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ public class ProductUpgraderInfoTests
{
private Mock<PhysicalFileSystem> mockFileSystem;
private ProductUpgraderInfo productUpgraderInfo;

private string upgradeDirectory;

private string expectedNewVersionExistsFileName = "HighestAvailableVersion";
private string expectedNewVersionExistsFilePath;
private MockTracer tracer;

[SetUp]
public void SetUp()
{
this.upgradeDirectory = GVFSPlatform.Instance.GetDataRootForGVFSComponent(ProductUpgraderInfo.UpgradeDirectoryName);
this.upgradeDirectory = ProductUpgraderInfo.GetUpgradeBasicDataDirectory();
this.expectedNewVersionExistsFilePath = Path.Combine(this.upgradeDirectory, this.expectedNewVersionExistsFileName);
this.mockFileSystem = new Mock<PhysicalFileSystem>();

Expand Down
14 changes: 14 additions & 0 deletions GVFS/GVFS.UnitTests/Mock/Common/MockPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class MockPlatform : GVFSPlatform

public override string Name { get => "Mock"; }

public override string GVFSConfigPath { get => Path.Combine("mock:", LocalGVFSConfig.FileName); }

public override GVFSPlatformConstants Constants { get; } = new MockPlatformConstants();

public HashSet<int> ActiveProcesses { get; } = new HashSet<int>();
Expand Down Expand Up @@ -100,6 +102,16 @@ public override Dictionary<string, string> GetPhysicalDiskInfo(string path, bool
{
return new Dictionary<string, string>();
}

public override string GetUpgradeProtectedDataDirectory()
{
return this.GetDataRootForGVFSComponent(ProductUpgraderInfo.UpgradeDirectoryName);
}

public override string GetUpgradeNonProtectedDataDirectory()
{
return this.GetDataRootForGVFSComponent(ProductUpgraderInfo.UpgradeDirectoryName);
}

public override void InitializeEnlistmentACLs(string enlistmentPath)
{
Expand Down Expand Up @@ -216,6 +228,8 @@ public override HashSet<string> UpgradeBlockingProcesses
{
get { return new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "GVFS", "GVFS.Mount", "git", "wish", "bash" }; }
}

public override bool SupportsInlineUpgrade { get; } = false;
}
}
}
Loading