diff --git a/Kudu.Contracts/Scan/IScanManager.cs b/Kudu.Contracts/Scan/IScanManager.cs index 55c93da3..e69cff6a 100644 --- a/Kudu.Contracts/Scan/IScanManager.cs +++ b/Kudu.Contracts/Scan/IScanManager.cs @@ -10,7 +10,8 @@ Task StartScan( String timeout, String mainScanDirPath, String id, - String host); + String host, + Boolean checkModified); Task GetScanStatus( String scanId, diff --git a/Kudu.Core/Scan/ScanManager.cs b/Kudu.Core/Scan/ScanManager.cs index ffcb4529..a1fe0bf4 100644 --- a/Kudu.Core/Scan/ScanManager.cs +++ b/Kudu.Core/Scan/ScanManager.cs @@ -153,7 +153,7 @@ private void ModifyManifestFile(JObject fileObj, string directoryPath) } - public async Task StartScan(String timeout,String mainScanDirPath,String id, String host) + public async Task StartScan(String timeout,String mainScanDirPath,String id, String host, Boolean checkModified) { using (_tracer.Step("Start scan in the background")) { @@ -169,6 +169,18 @@ public async Task StartScan(String timeout,String mainScanDir //Create unique scan folder and scan status file _scanLock.LockOperation(() => { + //This means user wants to start a scan without checking for file changes after previous scan + //Delete the manifest file containing last updated timestamps of files + //This will force a scan to start irrespective of changes made to files + if (!checkModified) + { + String manifestPath = Path.Combine(mainScanDirPath, Constants.ScanManifest); + if (FileSystemHelpers.FileExists(manifestPath)) + { + FileSystemHelpers.DeleteFileSafe(manifestPath); + } + } + //Check if files are modified if (CheckModifications(mainScanDirPath)) { diff --git a/Kudu.Services/Scan/ScanController.cs b/Kudu.Services/Scan/ScanController.cs index bf89d094..e8fbe5f1 100644 --- a/Kudu.Services/Scan/ScanController.cs +++ b/Kudu.Services/Scan/ScanController.cs @@ -32,7 +32,7 @@ public ScanController(ITracer tracer, IScanManager scanManager, IEnvironment web } [HttpGet] - public IActionResult ExecuteScan([FromQuery] string timeout) + public IActionResult ExecuteScan([FromQuery] string timeout,[FromQuery] Boolean checkModified = true) { if (timeout == null || timeout.Length == 0) @@ -40,9 +40,14 @@ public IActionResult ExecuteScan([FromQuery] string timeout) timeout = Constants.ScanTimeOutMillSec; } + if(checkModified == null) + { + checkModified = true; + } + //Start async scanning String id = DateTime.UtcNow.ToString("yyy-MM-dd_HH-mm-ssZ"); - var result = _scanManager.StartScan(timeout, mainScanDirPath, id, Request.Headers["Host"]); + var result = _scanManager.StartScan(timeout, mainScanDirPath, id, Request.Headers["Host"],checkModified); ScanUrl obj; //Check if files were modified after last scan