Skip to content

Commit

Permalink
Centralize business logic for starting background prefetch.
Browse files Browse the repository at this point in the history
Move the check for unattended enlistment from InProcessMount
to BackgroundPrefetcher.
  • Loading branch information
jrbriggs committed Aug 17, 2018
1 parent 55a37bb commit f858bca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions GVFS/GVFS.Common/Prefetch/BackgroundPrefetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public BackgroundPrefetcher(ITracer tracer, GVFSEnlistment enlistment, PhysicalF

this.prefetchJobThread = null;

if (gitObjects.IsUsingCacheServer())
if (gitObjects.IsUsingCacheServer() && !GVFSEnlistment.IsUnattended(tracer))
{
this.prefetchJobTimer = new Timer((state) => this.LaunchPrefetchJobIfIdle(), null, this.timerPeriod, this.timerPeriod);
this.tracer.RelatedInfo(nameof(BackgroundPrefetcher) + ": starting background prefetch timer");
}
else
{
this.tracer.RelatedInfo(nameof(BackgroundPrefetcher) + ": no configured cache server, not starting background prefetch timer");
this.tracer.RelatedInfo(nameof(BackgroundPrefetcher) + ": no configured cache server or enlistment is unattended, not starting background prefetch timer");
}
}

Expand Down
6 changes: 1 addition & 5 deletions GVFS/GVFS.Mount/InProcessMount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,7 @@ private void MountAndStartWorkingDirectoryCallbacks(CacheServerInfo cache)
}

this.fileSystemCallbacks = this.CreateOrReportAndExit(() => new FileSystemCallbacks(this.context, this.gitObjects, RepoMetadata.Instance, virtualizer, gitStatusCache), "Failed to create src folder callback listener");

if (!this.context.Unattended)
{
this.prefetcher = this.CreateOrReportAndExit(() => new BackgroundPrefetcher(this.tracer, this.enlistment, this.context.FileSystem, this.gitObjects), "Failed to start background prefetcher");
}
this.prefetcher = this.CreateOrReportAndExit(() => new BackgroundPrefetcher(this.tracer, this.enlistment, this.context.FileSystem, this.gitObjects), "Failed to start background prefetcher");

int majorVersion;
int minorVersion;
Expand Down

0 comments on commit f858bca

Please sign in to comment.