Skip to content

Upgrader: copy entire application directory#1228

Merged
jamill merged 2 commits into
microsoft:masterfrom
jamill:upgrader_tasks/copy_directory
Jun 3, 2019
Merged

Upgrader: copy entire application directory#1228
jamill merged 2 commits into
microsoft:masterfrom
jamill:upgrader_tasks/copy_directory

Conversation

@jamill
Copy link
Copy Markdown
Member

@jamill jamill commented May 31, 2019

When upgrading VFS for Git via the built-in upgrade logic, the upgrade verb will copy the upgrader application to a temporary directory, and run the upgrade app from the temporary directory. The main reason for this is so that the upgrade application can update the original application without open file handles getting in the way (and preventing the deletion of the application that is being updated).

The upgrade verb currently has a hard coded list of dependencies (files) required for the upgrader application to run. This can be fragile as we need to keep this list in sync with the actual dependencies, across multiple platforms. This can easily break if the dependencies change, and we update the list of files included with the installer, but not with the upgrader application. A specific occurrence of this happened in #1144.

Instead, just copy over the whole VFS for Git application directory when creating a temporary copy of the upgrader application to run. We might copy over a few additional files, but this should not cause any noticeable downsides.

TODO:

@jamill jamill mentioned this pull request May 31, 2019
15 tasks
directory.Delete();
}

public virtual void CopyDirectory(string source, string destination)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming nit: CopyDirectoryRecursive ?

@jamill jamill force-pushed the upgrader_tasks/copy_directory branch from 7ed3548 to 28a6da1 Compare June 1, 2019 02:39
jamill added 2 commits May 31, 2019 23:02
Teach PhysicalFileSystem the ability to copy an entire directory to a
destination path.
When upgrading VFS for Git via the built-in upgrade logic, the upgrade verb
will copy the upgrader application to a temporary directory, and run the
upgrade app from the temporary directory. The main reason for this is so that
the upgrade application can update the original application without open file
handles getting in the way (and preventing the deletion of the application that
is being updated).

The upgrade verb currently has a hard coded list of dependencies (files)
required for the upgrader application to run. This can be fragile as we need to
keep this list in sync with the actual dependencies, across multiple platforms.
This can easily break if the dependencies change, and we update the list of
files included with the installer, but not with the upgrader application. A
specific occurrence of this happened in microsoft#1144.

Instead, just copy over the whole VFS for Git application directory when
creating a temporary copy of the upgrader application to run. We might copy
over a few additional files, but this should not cause any noticeable
downsides.
@jamill jamill force-pushed the upgrader_tasks/copy_directory branch from 28a6da1 to 55bb915 Compare June 1, 2019 03:04
Copy link
Copy Markdown
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your "Tests" TODO. I'm assuming you just want a unit test on the recursive copy, right?

Is there any reason the CopyDirectoryRecursive() method shouldn't be an extension method on a FileSystem object? That would allow calling it on a mock object during the test.

I'm assuming our functional tests already cover what we can in the upgrade scenario.

@jamill
Copy link
Copy Markdown
Member Author

jamill commented Jun 3, 2019

I see your "Tests" TODO. I'm assuming you just want a unit test on the recursive copy, right?

I have been thinking about how to test this. My initial idea was to do a unit test to verify that a source directory (with some structure) was copied to a destination directory as expected, but then I would be testing the PhysicalFileSystem with a MockPhysicalFileSystem. Another thought was to just make a functional test for this...

Is there any reason the CopyDirectoryRecursive() method shouldn't be an extension method on a FileSystem object? That would allow calling it on a mock object during the test.

That might help with how to test this. I don't think there is any reason why it couldn't be an extension method. We don't have any other extension methods for this class (yet), so this would be the first. It seems similar in function to existing methods such as DeleteDirectory, so I wanted to keep them close.

I'm assuming our functional tests already cover what we can in the upgrade scenario.

I think we are a bit thin here - we have discussed improving this, and I added a GitHub issue to track this work (in case we don't have an existing issue).

@jamill
Copy link
Copy Markdown
Member Author

jamill commented Jun 3, 2019

I am going to proceed with this change as is. I included the test topic as a deferred / follow up item in the top level issue tracking the macOS upgrader (#1129)

@jamill jamill merged commit dc5a581 into microsoft:master Jun 3, 2019
@jrbriggs jrbriggs added this to the M155 milestone Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants