From d9c4ec048163a71c2b47049c3112f6b0967ddbfe Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Tue, 27 Dec 2022 11:42:18 +0100 Subject: [PATCH] check file/dir exists before trying to delete --- zero/FileStorage/PhysicalFileSystem.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zero/FileStorage/PhysicalFileSystem.cs b/zero/FileStorage/PhysicalFileSystem.cs index c5b3cf33..4248c828 100644 --- a/zero/FileStorage/PhysicalFileSystem.cs +++ b/zero/FileStorage/PhysicalFileSystem.cs @@ -119,6 +119,12 @@ public class PhysicalFileSystem : IFileSystem try { string resolvedPath = ResolvePath(path); + + if (!File.Exists(resolvedPath)) + { + return Task.CompletedTask; + } + File.Delete(resolvedPath); return Task.CompletedTask; } @@ -256,6 +262,12 @@ public class PhysicalFileSystem : IFileSystem try { string resolvedPath = ResolvePath(path); + + if (!Directory.Exists(resolvedPath)) + { + return Task.CompletedTask; + } + Directory.Delete(resolvedPath, recursive); return Task.CompletedTask; }