Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalar.Service: unregister repo when it's not on disk #206

Merged
merged 1 commit into from
Oct 31, 2019

Conversation

wilbaker
Copy link
Member

Part of the work required for #111

Update the RepoRegistry to check if the enlistment root
exists on disk before attempting to run the maintenance
verb against it. If the enlistment root does not exist
on disk, but it's root directory does exist, then
also remove the repo from the registry.

Checking that the root of the enlistment path exists
before removing the repo from the registry ensures that
we will not remove repos that are temporarily unavailable
(e.g. due to Bitlocker or a removable drive not being
present). See the discussion in
microsoft/VFSForGit#359 for details.

// Unregister the repo, but only after confirming that its volume still
// exists (or is empty/whitespace). If the volume does not exist we'll
// assume the drive was removed or is encrypted, and we'll leave the repo
// in the registry (but we won't run maintenance on it).
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: This check is very Windows specific. I suspect that on Mac this.fileSystem.DirectoryExists(rootPath) will always succeed because the root will always be /.

If we find that people frequently clone to removable drives (that are frequently removed) we might need to make this check smarter or the service will unregister the repos that live on the (detached) removable drive.

cc: @jrbriggs @derrickstolee as FYI

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense.

Could you reorganize the heavily-nested if statements here?

if (volume does not exist) {
   log;
   continue;
}

if (directory does not exist) {
   try remove;
   log result;
   continue;
}

run maintenance;

@wilbaker
Copy link
Member Author

Filed #207 for an issue I found with scalar maintenance crashing when its underlying directory is deleted.

That issue is unrelated to the changes in this PR.

Copy link
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.

Approved with suggestion.

Update the RepoRegistry to check if the enlistment root
exists on disk before attempting to run the maintenance
verb against it.  If the enlistment root does not exist
on disk, but it's root directory *does* exist, then
also remove the repo from the registry.

Checking that the root of the enlistment path exists
before removing the repo from the registry ensures that
we will not remove repos that are temporarily unavailable
(e.g. due to Bitlocker or a removable drive not being
present). See the discussion in
microsoft/VFSForGit#359 for details.
@wilbaker wilbaker merged commit e6104c4 into microsoft:master Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants