Skip to content

Commit

Permalink
Merge pull request #4002 from Ginger-Automation/Releases/Beta
Browse files Browse the repository at this point in the history
Handled Screenshots folder not found issue
  • Loading branch information
Maheshkale447 authored Nov 18, 2024
2 parents a4cdca6 + c84b812 commit d8c96c4
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions Ginger/GingerCoreNET/Logger/WebReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public LiteDbRunSet RunNewHtmlReport(string reportResultsFolderPath = "", string
IoHandler.Instance.TryFolderDelete(rootFolder);
}
IoHandler.Instance.CopyFolderRec(clientAppFolderPath, ReportrootPath, true);

if(!Directory.Exists(Path.Combine(ReportrootPath, "assets", "screenshots")))
{
Directory.CreateDirectory(Path.Combine(ReportrootPath, "assets", "screenshots"));
}
}
}
catch (Exception ex)
Expand All @@ -98,9 +93,9 @@ public LiteDbRunSet RunNewHtmlReport(string reportResultsFolderPath = "", string
{
return lightDbRunSet;
}
IoHandler.Instance.DeleteFoldersData(Path.Combine(ReportrootPath, "assets", "Execution_Data"));
IoHandler.Instance.DeleteFoldersData(Path.Combine(ReportrootPath, "assets", "screenshots"));
IoHandler.Instance.DeleteFoldersData(Path.Combine(ReportrootPath, "assets", "artifacts"));

CleanReportFolders(ReportrootPath);

LiteDbManager dbManager = new LiteDbManager(new ExecutionLoggerHelper().GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder));
lightDbRunSet = dbManager.GetLatestExecutionRunsetData(runSetGuid);
lightDbRunSet.SetAllIterationElementsRecursively(WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<HTMLReportConfiguration>().First(r => r.IsDefault).ShowAllIterationsElements);
Expand All @@ -116,6 +111,48 @@ public LiteDbRunSet RunNewHtmlReport(string reportResultsFolderPath = "", string
return lightDbRunSet;
}

/// <summary>
/// Cleans the report folders by deleting data in specified subdirectories.
/// If the directories do not exist, they are created.
/// </summary>
/// <param name="ReportrootPath">The root path of the report folders.</param>
private static void CleanReportFolders(string ReportrootPath)
{
try
{
try
{
IoHandler.Instance.DeleteFoldersData(Path.Combine(ReportrootPath, "assets", "Execution_Data"));
}
catch (DirectoryNotFoundException)
{
Directory.CreateDirectory(Path.Combine(ReportrootPath, "assets", "Execution_Data"));
}

try
{
IoHandler.Instance.DeleteFoldersData(Path.Combine(ReportrootPath, "assets", "screenshots"));
}
catch (DirectoryNotFoundException)
{
Directory.CreateDirectory(Path.Combine(ReportrootPath, "assets", "screenshots"));
}

try
{
IoHandler.Instance.DeleteFoldersData(Path.Combine(ReportrootPath, "assets", "artifacts"));
}
catch (DirectoryNotFoundException)
{
Directory.CreateDirectory(Path.Combine(ReportrootPath, "assets", "artifacts"));
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error while cleaning up reports folder", ex);
}
}

private void RemoveSkippedItems(LiteDbRunSet liteDbRunSet)
{
HTMLReportConfiguration _HTMLReportConfig = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<HTMLReportConfiguration>().FirstOrDefault(x => (x.IsDefault == true));
Expand Down

0 comments on commit d8c96c4

Please sign in to comment.