Skip to content

Commit 7b31909

Browse files
author
scottbommarito
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into dev
# Conflicts: # src/NuGet.Server.Core/Infrastructure/ServerPackageRepository.cs
2 parents 4eb0fec + befe6f1 commit 7b31909

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/NuGet.Server.Core/Infrastructure/ServerPackageRepository.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public void ClearCache()
587587

588588
private void MonitorFileSystem(bool monitor)
589589
{
590-
if (!_runBackgroundTasks)
590+
if (!EnableFileSystemMonitoring || !_runBackgroundTasks)
591591
{
592592
return;
593593
}
@@ -617,7 +617,7 @@ private void MonitorFileSystem(bool monitor)
617617
private void RegisterFileSystemWatcher()
618618
{
619619
// When files are moved around, recreate the package cache
620-
if (_runBackgroundTasks && _fileSystemWatcher == null && !string.IsNullOrEmpty(Source) && Directory.Exists(Source))
620+
if (EnableFileSystemMonitoring && _runBackgroundTasks && _fileSystemWatcher == null && !string.IsNullOrEmpty(Source) && Directory.Exists(Source))
621621
{
622622
// ReSharper disable once UseObjectOrCollectionInitializer
623623
_fileSystemWatcher = new FileSystemWatcher(Source);
@@ -713,6 +713,15 @@ private bool EnableFrameworkFiltering
713713
}
714714
}
715715

716+
private bool EnableFileSystemMonitoring
717+
{
718+
get
719+
{
720+
// If the setting is misconfigured, treat it as on (backwards compatibility).
721+
return _settingsProvider.GetBoolSetting("enableFileSystemMonitoring", true);
722+
}
723+
}
724+
716725
private string GetPackageFileName(string packageId, SemanticVersion version)
717726
{
718727
return string.Format(TemplateNupkgFilename, packageId, version.ToNormalizedString());

src/NuGet.Server/Web.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656
Uncomment the following configuration entry to enable NAT support.
5757
-->
5858
<!-- <add key="aspnet:UseHostHeaderForRequestUrl" value="true" /> -->
59+
<!--
60+
Set enableFileSystemMonitoring to true (default) to enable file system monitoring (which will update the package cache appropriately on file system changes).
61+
Set it to false to disable file system monitoring.
62+
NOTE: Disabling file system monitoring may result in increased storage capacity requirements as package cache may only be purged by a background job running
63+
on a fixed 1-hour interval.
64+
-->
65+
<add key="enableFileSystemMonitoring" value="true" />
5966
</appSettings>
6067
<!--
6168
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

0 commit comments

Comments
 (0)