Skip to content

Commit

Permalink
Manually loop over directories
Browse files Browse the repository at this point in the history
  • Loading branch information
devedse committed Aug 9, 2020
1 parent b832acd commit 7ccc054
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion WebOptimizationProject/GitHubRepositoryOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public async Task GoOptimize(bool cleanupAfterwards, Repository repository, stri
{
Console.WriteLine($"Cleaning up local files '{clonedRepo}'...");
Directory.SetCurrentDirectory(dirOfClonedRepos);
Directory.Delete(clonedRepo, true);
CleanupRecursively(clonedRepo);
//Directory.Delete(clonedRepo, true);
Console.WriteLine($"Directory {clonedRepo} removed.");
}
}
Expand All @@ -175,5 +176,22 @@ private async Task<IEnumerable<OptimizableFile>> GoOptimize(string dir, WopConfi

return optimizedFileResults;
}

private void CleanupRecursively(string path)
{
foreach (var file in Directory.GetFiles(path))
{
Console.WriteLine($"Deleting file: {file}");
File.Delete(file);
}

foreach (var dir in Directory.GetDirectories(path))
{
CleanupRecursively(dir);
}

Console.WriteLine($"Deleting dir: {path}");
Directory.Delete(path);
}
}
}

0 comments on commit 7ccc054

Please sign in to comment.