Skip to content

Commit 710e9ec

Browse files
committed
don't try to remove the directory if it doesn't exists in C#
1 parent 3424132 commit 710e9ec

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

plugins/csharp/src/plugin.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ impl CSharpPlugin {
3838
fn runner_needs_to_be_extracted(target: &Path) -> Result<bool, CSharpError> {
3939
log::debug!("verifying C# runner integrity at {}", target.display());
4040

41+
// no need to check the zip contents if the directory doesn't even exist
42+
if !target.exists() {
43+
return Ok(true);
44+
}
45+
4146
let mut zip = ZipArchive::new(Cursor::new(TMC_CSHARP_RUNNER))?;
4247
for i in 0..zip.len() {
4348
let file = zip.by_index(i)?;
@@ -95,7 +100,10 @@ impl CSharpPlugin {
95100
Some(cache_dir) => {
96101
let runner_dir = cache_dir.join("tmc").join("tmc-csharp-runner");
97102
if Self::runner_needs_to_be_extracted(&runner_dir)? {
98-
file_util::remove_dir_all(&runner_dir)?;
103+
if runner_dir.exists() {
104+
// clear the directory if it exists
105+
file_util::remove_dir_all(&runner_dir)?;
106+
}
99107
Self::extract_runner_to_dir(&runner_dir)?;
100108
}
101109
Ok(runner_dir)

0 commit comments

Comments
 (0)