Permalink
Browse files

Delete the folder contents not the target folder when doing first dep…

…loyment.
  • Loading branch information...
1 parent 2099172 commit e7f731457b1034d40a7e5a040186632194d8f197 @davidfowl davidfowl committed Feb 9, 2012
Showing with 24 additions and 14 deletions.
  1. +2 −2 Kudu.Core/Deployment/DeploymentHelper.cs
  2. +22 −12 Kudu.Core/Infrastructure/FileSystemHelpers.cs
@@ -27,8 +27,8 @@ public static void CopyWithManifest(string sourcePath, string destinationPath, I
}
else
{
- // On first deployment, delete the destination path before copying
- FileSystemHelpers.DeleteDirectorySafe(destinationPath);
+ // On first deployment, delete the contents of the destination path before copying
+ FileSystemHelpers.DeleteDirectoryContentsSafe(destinationPath);
// If there's no manifest then there's nothing to copy
FileSystemHelpers.Copy(sourcePath, destinationPath);
@@ -25,6 +25,11 @@ public static void DeleteDirectorySafe(string path)
DeleteFileSystemInfo(new DirectoryInfoWrapper(new DirectoryInfo(path)));
}
+ public static void DeleteDirectoryContentsSafe(string path)
+ {
+ DeleteDirectoryContentsSafe(new DirectoryInfoWrapper(new DirectoryInfo(path)));
+ }
+
internal static string EnsureDirectory(string path)
{
return EnsureDirectory(new FileSystem(), path);
@@ -74,22 +79,27 @@ private static void DeleteFileSystemInfo(FileSystemInfoBase fileSystemInfo)
if (directoryInfo != null)
{
- try
+ DeleteDirectoryContentsSafe(directoryInfo);
+ }
+
+ DoSafeAction(fileSystemInfo.Delete);
+ }
+
+ private static void DeleteDirectoryContentsSafe(DirectoryInfoBase directoryInfo)
+ {
+ try
+ {
+ if (directoryInfo.Exists)
{
- if (directoryInfo.Exists)
+ foreach (var fsi in directoryInfo.GetFileSystemInfos())
{
- foreach (var dirInfo in directoryInfo.GetFileSystemInfos())
- {
- DeleteFileSystemInfo(dirInfo);
- }
+ DeleteFileSystemInfo(fsi);
}
}
- catch
- {
- }
}
-
- DoSafeAction(fileSystemInfo.Delete);
+ catch
+ {
+ }
}
private static void DoSafeAction(Action action)
@@ -152,7 +162,7 @@ internal static void Copy(string sourcePath, string destinationPath, bool skipSc
Copy(sourcePath, destinationPath, sourceSubDirectory, targetSubDirectory, createDirectoryInfo, skipScmFolder);
}
}
-
+
internal static void SmartCopy(string sourcePath,
string destinationPath,
Func<string, bool> existsInPrevious,

0 comments on commit e7f7314

Please sign in to comment.