Browse Source
Merge pull request #1616 from colinin/blob-exists
refactor(blobmanagement): Scope the blob existence check by container id
pull/1626/head
i2nets
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
7 additions and
10 deletions
-
aspnet-core/modules/blob-management/LINGYUN.Abp.BlobManagement.Application/LINGYUN/Abp/BlobManagement/Integration/BlobIntegrationService.cs
-
aspnet-core/modules/blob-management/LINGYUN.Abp.BlobManagement.Domain/LINGYUN/Abp/BlobManagement/IBlobRepository.cs
-
aspnet-core/modules/blob-management/LINGYUN.Abp.BlobManagement.EntityFrameworkCore/LINGYUN/Abp/BlobManagement/EntityFrameworkCore/EfCoreBlobRepository.cs
|
|
|
@ -83,7 +83,8 @@ public class BlobIntegrationService : BlobAppServiceBase, IBlobIntegrationServic |
|
|
|
try |
|
|
|
{ |
|
|
|
var blobName = HttpUtility.UrlDecode(input.BlobName); |
|
|
|
return await BlobRepository.ExistsAsync(input.ContainerName, blobName); |
|
|
|
var blobContainer = await BlobContainerRepository.GetByNameAsync(BlobManager.GetBlobProvider(), input.ContainerName); |
|
|
|
return await BlobRepository.ExistsAsync(blobName, blobContainer.Id); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -10,8 +10,8 @@ namespace LINGYUN.Abp.BlobManagement; |
|
|
|
public interface IBlobRepository : IBasicRepository<Blob, Guid> |
|
|
|
{ |
|
|
|
Task<bool> ExistsAsync( |
|
|
|
string containerName, |
|
|
|
string fullName, |
|
|
|
Guid? containerId = null, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task<Blob?> FindByNameAsync( |
|
|
|
|
|
|
|
@ -20,17 +20,13 @@ public class EfCoreBlobRepository : EfCoreRepository<IBlobManagementDbContext, B |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task<bool> ExistsAsync( |
|
|
|
string containerName, |
|
|
|
string fullName, |
|
|
|
Guid? containerId = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
|
|
|
|
return await (from container in dbContext.Set<BlobContainer>() |
|
|
|
join blob in dbContext.Set<Blob>() |
|
|
|
on container.Id equals blob.ContainerId |
|
|
|
where container.Name == containerName && blob.FullName == fullName |
|
|
|
select blob) |
|
|
|
return await (await GetQueryableAsync()) |
|
|
|
.Where(x => x.FullName == fullName) |
|
|
|
.WhereIf(containerId.HasValue, x => x.ContainerId == containerId) |
|
|
|
.AnyAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
|