Upgrader - platform specific directory creation#1225
Upgrader - platform specific directory creation#1225jamill merged 4 commits intomicrosoft:masterfrom
Conversation
derrickstolee
left a comment
There was a problem hiding this comment.
Looks promising to start. I'd unify the cross-platform pattern to not have Windows be the default, but instead be at the same level as Mac. This means having an abstract base class with an implementation for each platform.
It would be nice to do some research into the Linux platform a bit here so we can figure out what can be combined into a POSIX platform class and extend that with Mac and Linux stuff. For example: creating directories with given permissions will be the same in each.
Windows -> Base
POSIX -> Base
Mac -> POSIX
Linux -> POSIX
|
|
||
| namespace GVFS.Common | ||
| { | ||
| public class MacProductUpgraderPlatformStrategy : ProductUpgraderPlatformStrategy |
There was a problem hiding this comment.
Still looking but I'm not sure what PlatformStrategy means.
I also don't think we should have platform specific code going into GVFS.Common. Looking at this and it seems these should be a part of IPlatformFileSystem with a TryPrepareDirectory(string path, out string error). We might even be able to remove the 2 permission method from that interface since they appear only to be for Windows.
bool TryCreateDirectoryWithAdminAndUserModifyPermissions(string directoryPath, out string error);
bool TryCreateOrUpdateDirectoryToAdminModifyPermissions(ITracer tracer, string directoryPath, out string error);
There was a problem hiding this comment.
it seems these should be a part of IPlatformFileSystem with a TryPrepareDirectory(string path, out string error)
I like this idea - but the problem I ran into is that that action depends on the directory (which the upgrader has the most context on).
There was a problem hiding this comment.
If there is an appropriate abstraction here, I am open to adding these directly to the IPlatformFileSystem class, but I haven't figured out a non-upgrader specific abstraction here... I will continue to think about this.
| <When Condition="'$(OS)' == 'Windows_NT'"> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks> | ||
| <DefineConstants>$(DefineConstants);WINDOWS_BUILD</DefineConstants> |
There was a problem hiding this comment.
Looks like this project is already referencing the Windows or the Mac Platform projects so why can't we have the platform specific code live in those projects instead of adding another way to create platform specific code?
There was a problem hiding this comment.
That is an option - but then we are putting upgrader specific code in the platform project...
There was a problem hiding this comment.
I will look at moving this into platform specific projects
There was a problem hiding this comment.
After thinking about this a bit more - I moved the platform specific code out of the Common project, but I am still am not sure about the GVFS.Upgrader project. This project is almost a separate application, and I didn't want to bring high level "other application" specific logic into the Platform classes.
I am open to thoughts on this, but I wasn't going to convert this just yet.
983ccc9 to
92118b0
Compare
|
Thanks @derrickstolee for the review!
I think this makes sense as a goal. The problem I ran into is that we have a bunch of existing tests that exercise the current concrete implementation. If we make the
Good idea! I think a lot (or at least some) of the logic that is in the Mac specific class can actually go in the POSIX layer instead (as you noted). |
92118b0 to
0e68664
Compare
| ITracer tracer, | ||
| string lockPath); | ||
|
|
||
| public abstract ProductUpgraderPlatformStrategy CreateProductUpgraderPlatformInteractions( |
There was a problem hiding this comment.
I think the ProductUpgraderPlatformStrategy name is overly verbose and at the same time not clear. I don't think the Interactions suffix is any better... Still thinking for a better name.
4ec26d1 to
19a2034
Compare
130a5ea to
81d9f15
Compare
derrickstolee
left a comment
There was a problem hiding this comment.
Just a few lingering questions.
|
|
||
| namespace GVFS.Upgrader | ||
| { | ||
| [Verb("UpgradeOrchestrator", HelpText = "Upgrade VFS for Git.")] |
There was a problem hiding this comment.
This Verb annotation seems out of place.
There was a problem hiding this comment.
This usage is different than how we generally structure this in our product, but it does match the intended usage:
https://github.com/commandlineparser/commandline#for-verbs
I think we could ask whether we need this to be a verb, as this is being used to process command line arguments for a program that doesn't actually have verbs. I will note this as a potential cleanup.
81d9f15 to
6b45433
Compare
alameenshah
left a comment
There was a problem hiding this comment.
Testing notes - there seems to be an issue on Windows.
> gvfs upgrade
Checking for GVFS upgrades...Failed
ERROR: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
6b45433 to
b32e997
Compare
Instead of querying interop services at runtime (with a dll that is not included with the windows install), determine this at compile time using the under construction flags.
b32e997 to
bc21b84
Compare
alameenshah
left a comment
There was a problem hiding this comment.
Thank you for fixing the issue.
Looking Good now.
The upgrade logic between the different platforms has some high level differences that need to be accounted for:
There are other ways to handle the platform differences, but including:
performing the re-ACLing of directories on non-windows platforms. We could re-use more of the top level logic, but then we would be doing extra work with ACLs that is not needed.
Do no re-ACL on non-windows platforms. I did not want to cause confusion with the methods not doing what they advertise (especially around ACLs), in case someone misses this subtlety in the future. This would be hard from a maintainability standpoint...
There is still some further work I need to do here to get this into shape, but I wanted to put this up for initial feedback on the general direction.