Skip to content

Commit 5324d3b

Browse files
committed
Add file storage tests
1 parent 896f145 commit 5324d3b

File tree

2 files changed

+264
-34
lines changed

2 files changed

+264
-34
lines changed

src/BaGet.Core/Services/FilePackageStorageService.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ public async Task SavePackageContentAsync(
2424
Stream packageStream,
2525
Stream nuspecStream,
2626
Stream readmeStream,
27-
CancellationToken cancellationToken)
27+
CancellationToken cancellationToken = default)
2828
{
29+
package = package ?? throw new ArgumentNullException(nameof(package));
30+
packageStream = packageStream ?? throw new ArgumentNullException(nameof(packageStream));
31+
nuspecStream = nuspecStream ?? throw new ArgumentNullException(nameof(nuspecStream));
32+
2933
var lowercasedId = package.Id.ToLowerInvariant();
3034
var lowercasedNormalizedVersion = package.VersionString.ToLowerInvariant();
3135

@@ -86,9 +90,15 @@ public Task DeleteAsync(string id, NuGetVersion version)
8690
var nuspecPath = NuspecPath(lowercasedId, lowercasedNormalizedVersion);
8791
var readmePath = ReadmePath(lowercasedId, lowercasedNormalizedVersion);
8892

89-
File.Delete(packagePath);
90-
File.Delete(nuspecPath);
91-
File.Delete(readmePath);
93+
try
94+
{
95+
File.Delete(packagePath);
96+
File.Delete(nuspecPath);
97+
File.Delete(readmePath);
98+
}
99+
catch (DirectoryNotFoundException)
100+
{
101+
}
92102

93103
return Task.CompletedTask;
94104
}

0 commit comments

Comments
 (0)