Skip to content

Commit

Permalink
Added checkModified as a param to override manifest file checking (Az…
Browse files Browse the repository at this point in the history
  • Loading branch information
ppvasude authored and sanchitmehta committed Aug 8, 2019
1 parent 6f18e57 commit ee1015b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Kudu.Contracts/Scan/IScanManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Task<ScanRequestResult> StartScan(
String timeout,
String mainScanDirPath,
String id,
String host);
String host,
Boolean checkModified);

Task<ScanStatusResult> GetScanStatus(
String scanId,
Expand Down
14 changes: 13 additions & 1 deletion Kudu.Core/Scan/ScanManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void ModifyManifestFile(JObject fileObj, string directoryPath)

}

public async Task<ScanRequestResult> StartScan(String timeout,String mainScanDirPath,String id, String host)
public async Task<ScanRequestResult> StartScan(String timeout,String mainScanDirPath,String id, String host, Boolean checkModified)
{
using (_tracer.Step("Start scan in the background"))
{
Expand All @@ -169,6 +169,18 @@ public async Task<ScanRequestResult> 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))
{
Expand Down
9 changes: 7 additions & 2 deletions Kudu.Services/Scan/ScanController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ 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)
{
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
Expand Down

0 comments on commit ee1015b

Please sign in to comment.