Fix FileNotFoundException

This commit is contained in:
George Fleming committed 2016-04-28 08:44:20 -07:00
1 parent 967634f732
commit 1b1858cf09
1 file changed
+26 -19
@@ -3562,29 +3562,36 @@ namespace Microsoft.PowerShell.Commands
}
bool shouldRecurse = Recurse;
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(providerPath);
if (Platform.IsLinux && di != null && (di.Attributes & System.IO.FileAttributes.ReparsePoint) != 0)
bool linuxLink = false;
try
{
shouldRecurse = false;
}
else
{
if (!Recurse && hasChildren)
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(providerPath);
if (Platform.IsLinux && di != null && (di.Attributes & System.IO.FileAttributes.ReparsePoint) != 0)
{
// Get the localized prompt string
string prompt = StringUtil.Format(NavigationResources.RemoveItemWithChildren,resolvedPath.Path);
// Confirm the user wants to remove all children and the item even if
// they did not specify -recurse
if (!ShouldContinue (prompt, null, ref yesToAll, ref noToAll))
{
continue;
}
shouldRecurse = true;
shouldRecurse = false;
linuxLink = true;
}
}
catch (System.IO.FileNotFoundException)
{
// not a directory
}
if (!linuxLink && !Recurse && hasChildren)
{
// Get the localized prompt string
string prompt = StringUtil.Format(NavigationResources.RemoveItemWithChildren,resolvedPath.Path);
// Confirm the user wants to remove all children and the item even if
// they did not specify -recurse
if (!ShouldContinue (prompt, null, ref yesToAll, ref noToAll))
{
continue;
}
shouldRecurse = true;
}
// Now do the delete
// This calls the internal method since it is more efficient