Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…loyment.
  • Loading branch information...
commit e7f731457b1034d40a7e5a040186632194d8f197 1 parent 2099172
@davidfowl davidfowl authored
View
4 Kudu.Core/Deployment/DeploymentHelper.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);
View
34 Kudu.Core/Infrastructure/FileSystemHelpers.cs
@@ -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.
Something went wrong with that request. Please try again.