Skip to content

Commit

Permalink
Merge pull request #184: Centralize business logic for starting backg…
Browse files Browse the repository at this point in the history
…round prefetch.

Move the check for unattended enlistment from InProcessMount to BackgroundPrefetcher.
  • Loading branch information
jrbriggs authored Aug 17, 2018
2 parents fba3bce + 553615d commit 5c876fe
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 5c876fe

Please sign in to comment.