Browse files

Support optionally deleting wwwroot when deleting the repo

Going through Vfs to clean the web root was proving difficult, and doing it as part of repo deletion is more reliable
  • Loading branch information...
1 parent 975830b commit 6282410f4f1c97e822ce7d90375a73a2ae2021f3 @davidebbo davidebbo committed Dec 2, 2012
View
4 Kudu.Client/SourceControl/RemoteRepositoryManager.cs
@@ -19,9 +19,9 @@ public Task<RepositoryInfo> GetRepositoryInfo()
return Client.GetJsonAsync<RepositoryInfo>("info");
}
- public Task Delete()
+ public Task Delete(bool deleteWebRoot = false)
{
- return Client.DeleteSafeAsync(String.Empty);
+ return Client.DeleteSafeAsync(deleteWebRoot ? "?deleteWebRoot=1" : String.Empty);
}
}
}
View
11 Kudu.Services/SourceControl/LiveScmController.cs
@@ -52,7 +52,7 @@ public RepositoryInfo GetRepositoryInfo(HttpRequestMessage request)
/// Delete the repository
/// </summary>
[HttpDelete]
- public void Delete()
+ public void Delete(int deleteWebRoot = 0)
{
// Fail if a deployment is in progress
if (_deploymentLock.IsHeld)
@@ -78,6 +78,15 @@ public void Delete()
// Delete the ssh key
FileSystemHelpers.DeleteDirectorySafe(_environment.SSHKeyPath);
}
+
+ if (deleteWebRoot != 0)
+ {
+ using (_tracer.Step("Deleting web root"))
+ {
+ // Delete the wwwroot folder
+ FileSystemHelpers.DeleteDirectoryContentsSafe(_environment.WebRootPath);
+ }
+ }
}
/// <summary>
View
5 Kudu.TestHarness/ApplicationManager.cs
@@ -122,12 +122,9 @@ public static void Run(string applicationName, Action<ApplicationManager> action
if (KuduUtils.ReuseSameSiteForAllTests)
{
// In site reuse mode, clean out the existing site so we start clean
- appManager.RepositoryManager.Delete().Wait();
+ appManager.RepositoryManager.Delete(deleteWebRoot: true).Wait();
// Make sure we start with the correct default file as some tests expect it
- // Note that ideally we'd wipe out the entire wwwroot, but it's slightly non trivial over Vfs
- appManager.VfsWebRootManager.Delete("default.htm");
- appManager.VfsWebRootManager.Delete("index.htm");
appManager.VfsWebRootManager.WriteAllText("index.html", "<h1>The web site is under construction</h1>");
}

0 comments on commit 6282410

Please sign in to comment.