FileService: Null-check stored file before removal (#4535)

This commit is contained in:
d11n 2023-01-18 13:38:37 +01:00 committed by GitHub
parent 248401f534
commit 3cdb4f5b2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,8 +120,8 @@ namespace BTCPayServer.Storage.Services
return;
var provider = GetProvider(settings);
var storedFile = await _fileRepository.GetFile(fileId);
if (string.IsNullOrEmpty(userId) ||
storedFile.ApplicationUserId.Equals(userId, StringComparison.InvariantCultureIgnoreCase))
if (storedFile != null && (string.IsNullOrEmpty(userId) ||
storedFile.ApplicationUserId.Equals(userId, StringComparison.InvariantCultureIgnoreCase)))
{
await provider.RemoveFile(storedFile, settings);
await _fileRepository.RemoveFile(storedFile);