Display Drive detection warning only for multiple drives (#7589)

* indexer drive detection helper code to not show the warning for a single drive

* removed interface from the namespace due to stylecop

* removed interfac which no longer exists

* filter out only fixed drives in the system and ignore the removable drives

* changed text to not all files are indexed, from not all drives are idnexed

* add additional info in the comment
This commit is contained in:
Alekhya
2020-10-29 10:38:15 -07:00
committed by GitHub
parent e30393e18f
commit fdffe20c0b
7 changed files with 54 additions and 12 deletions

View File

@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.IO;
using System.Linq;
namespace Microsoft.Plugin.Indexer.DriveDetection
{
public class DriveInfoWrapper : IDriveInfoWrapper
{
private static readonly int DriveCount = GetDriveInfo();
private static int GetDriveInfo()
{
// To ignore removable type drives, CD ROMS, no root partitions which may not be formatted and only return the fixed drives in the system.
return DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).Count();
}
public int GetDriveCount() => DriveCount;
}
}

View File

@@ -10,18 +10,23 @@ namespace Microsoft.Plugin.Indexer.DriveDetection
private readonly IRegistryWrapper _registryHelper;
private readonly IDriveInfoWrapper _driveHelper;
public bool IsDriveDetectionWarningCheckBoxSelected { get; set; }
public IndexerDriveDetection(IRegistryWrapper registryHelper)
public IndexerDriveDetection(IRegistryWrapper registryHelper, IDriveInfoWrapper driveHelper)
{
_registryHelper = registryHelper;
_driveHelper = driveHelper;
GetEnhancedModeStatus();
}
// To display the warning when Enhanced mode is disabled and the Disable Drive detection check box in settings is unchecked
// To display the drive detection warning only when enhanced mode is disabled on a system which has multiple drives.
// Currently the warning would not be displayed if the enhanced mode is disabled when the user system has only a single fixed drive. However, this warning may be added in the future.
// This warning can be disabled by checking the disabled drive detection warning checkbox in settings.
public bool DisplayWarning()
{
return !(IsDriveDetectionWarningCheckBoxSelected || IsEnhancedModeEnabled);
return !(IsDriveDetectionWarningCheckBoxSelected || IsEnhancedModeEnabled || (_driveHelper.GetDriveCount() == 1));
}
// To look up the registry entry for enhanced search