public ActionResult GetArchive(string packageId) { Stream archiveStream = null; try { Stopwatch sw = new Stopwatch(); sw.Start(); _indexService.PurgeOldArchives(); archiveStream = _indexService.GetPackageAsArchive(packageId); sw.Stop(); _log.LogInformation($"Archive generation for package {packageId} took {0} seconds", sw.Elapsed.TotalSeconds); return(File(archiveStream, "application/octet-stream", $"{packageId}.zip")); } catch (PackageNotFoundException) { return(Responses.NotFoundError(this, $"Package ${packageId} not found.")); } catch (Exception ex) { if (archiveStream != null) { archiveStream.Close(); } _log.LogError(ex, "Unexpected error"); return(Responses.UnexpectedError()); } }
private async Task Tick() { while (_running) { try { _log.LogInformation("Daemon ticked"); if (_busy) { return; } _busy = true; _repositoryCleaner.Clean(); _indexService.PurgeOldArchives(); } finally { _busy = false; await Task.Delay(_tickInterval); } } }
public ActionResult Clean() { _repositoryCleaner.Clean(); _indexService.PurgeOldArchives(); return(new JsonResult(new { success = new { description = "Clean complete" } })); }