Skip to content

Commit e5cec1a

Browse files
authored
Simplify the logic since createdirectory won't fail if the directory already exists
1 parent 6e249e3 commit e5cec1a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Tasks/sdk-tasks/ExtractArchiveToDirectory.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ public override bool Execute()
9494

9595
CheckDestinationPath(destinationPath, fullDestDirPath);
9696

97-
if (!Directory.Exists(Path.Combine(DestinationDirectory, Path.GetDirectoryName(entry.FullName))))
98-
{
99-
Directory.CreateDirectory(Path.Combine(DestinationDirectory, Path.GetDirectoryName(entry.FullName)));
100-
}
97+
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
10198

10299
Log.LogMessage(Path.GetDirectoryName(entry.FullName));
103100
entry.ExtractToFile(destinationPath);
@@ -131,10 +128,9 @@ public override bool Execute()
131128
string destinationPath = Path.GetFullPath(Path.Combine(DestinationDirectory, entryName));
132129

133130
CheckDestinationPath(destinationPath, fullDestDirPath);
131+
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
134132

135133
Log.LogMessage(entryName);
136-
137-
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
138134
tarEntry.ExtractToFile(destinationPath, overwrite: true);
139135
}
140136
}

0 commit comments

Comments
 (0)