From bfce4c2752d98cc98e693e726ceb67b287140412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 30 May 2020 22:21:49 +0300 Subject: [PATCH] Should not pass the tenantId to the blob provider --- .../DefaultBlobFilePathCalculator.cs | 12 +- .../Volo/Abp/BlobStoring/BlobContainer.cs | 113 +++++++++--------- .../Volo/Abp/BlobStoring/BlobProviderArgs.cs | 7 +- .../Abp/BlobStoring/BlobProviderDeleteArgs.cs | 5 +- .../Abp/BlobStoring/BlobProviderExistsArgs.cs | 5 +- .../Abp/BlobStoring/BlobProviderGetArgs.cs | 5 +- .../Abp/BlobStoring/BlobProviderSaveArgs.cs | 5 +- .../BlogFilePathCalculator_Tests.cs | 16 ++- .../Database/DatabaseBlobProvider.cs | 26 ++-- .../IDatabaseBlobContainerRepository.cs | 2 +- .../Database/IDatabaseBlobRepository.cs | 6 +- .../EfCoreDatabaseBlobContainerRepository.cs | 5 +- .../EfCoreDatabaseBlobRepository.cs | 11 +- .../MongoDbDatabaseBlobContainerRepository.cs | 4 +- .../MongoDB/MongoDbDatabaseBlobRepository.cs | 14 +-- 15 files changed, 111 insertions(+), 125 deletions(-) diff --git a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs index 021ecd814d..1857b2e736 100644 --- a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs +++ b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs @@ -1,22 +1,30 @@ using System.IO; using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; namespace Volo.Abp.BlobStoring.FileSystem { public class DefaultBlobFilePathCalculator : IBlobFilePathCalculator, ITransientDependency { + protected ICurrentTenant CurrentTenant { get; } + + public DefaultBlobFilePathCalculator(ICurrentTenant currentTenant) + { + CurrentTenant = currentTenant; + } + public virtual string Calculate(BlobProviderArgs args) { var fileSystemConfiguration = args.Configuration.GetFileSystemConfiguration(); var blobPath = fileSystemConfiguration.BasePath; - if (args.TenantId == null) + if (CurrentTenant.Id == null) { blobPath = Path.Combine(blobPath, "host"); } else { - blobPath = Path.Combine(blobPath, "tenants", args.TenantId.Value.ToString("D")); + blobPath = Path.Combine(blobPath, "tenants", CurrentTenant.Id.Value.ToString("D")); } if (fileSystemConfiguration.AppendContainerNameToBasePath) diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobContainer.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobContainer.cs index 789271b6ee..d165a40316 100644 --- a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobContainer.cs +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobContainer.cs @@ -79,9 +79,9 @@ namespace Volo.Abp.BlobStoring protected BlobContainerConfiguration Configuration { get; } protected IBlobProvider Provider { get; } - + protected ICurrentTenant CurrentTenant { get; } - + protected ICancellationTokenProvider CancellationTokenProvider { get; } public BlobContainer( @@ -98,100 +98,101 @@ namespace Volo.Abp.BlobStoring CancellationTokenProvider = cancellationTokenProvider; } - public virtual Task SaveAsync( + public virtual async Task SaveAsync( string name, Stream stream, bool overrideExisting = false, CancellationToken cancellationToken = default) { - return Provider.SaveAsync( - new BlobProviderSaveArgs( - ContainerName, - Configuration, - name, - stream, - overrideExisting, - GetTenantIdOrNull(), - CancellationTokenProvider.FallbackToProvider(cancellationToken) - ) - ); + using (CurrentTenant.Change(GetTenantIdOrNull())) + { + await Provider.SaveAsync( + new BlobProviderSaveArgs( + ContainerName, + Configuration, + name, + stream, + overrideExisting, + CancellationTokenProvider.FallbackToProvider(cancellationToken) + ) + ); + } } - public virtual Task DeleteAsync( + public virtual async Task DeleteAsync( string name, CancellationToken cancellationToken = default) { - return Provider.DeleteAsync( - new BlobProviderDeleteArgs( - ContainerName, - Configuration, - name, - GetTenantIdOrNull(), - CancellationTokenProvider.FallbackToProvider(cancellationToken) - ) - ); + using (CurrentTenant.Change(GetTenantIdOrNull())) + { + return await Provider.DeleteAsync( + new BlobProviderDeleteArgs( + ContainerName, + Configuration, + name, + CancellationTokenProvider.FallbackToProvider(cancellationToken) + ) + ); + } } - public virtual Task ExistsAsync( + public virtual async Task ExistsAsync( string name, CancellationToken cancellationToken = default) { - return Provider.ExistsAsync( - new BlobProviderExistsArgs( - ContainerName, - Configuration, - name, - GetTenantIdOrNull(), - CancellationTokenProvider.FallbackToProvider(cancellationToken) - ) - ); + using (CurrentTenant.Change(GetTenantIdOrNull())) + { + return await Provider.ExistsAsync( + new BlobProviderExistsArgs( + ContainerName, + Configuration, + name, + CancellationTokenProvider.FallbackToProvider(cancellationToken) + ) + ); + } } public virtual async Task GetAsync( string name, CancellationToken cancellationToken = default) { - var stream = await Provider.GetOrNullAsync( - new BlobProviderGetArgs( - ContainerName, - Configuration, - name, - GetTenantIdOrNull(), - CancellationTokenProvider.FallbackToProvider(cancellationToken) - ) - ); + var stream = await GetOrNullAsync(name, cancellationToken); if (stream == null) { //TODO: Consider to throw some type of "not found" exception and handle on the HTTP status side - throw new AbpException($"Could not found the requested BLOB '{name}' in the container '{ContainerName}'!"); + throw new AbpException( + $"Could not found the requested BLOB '{name}' in the container '{ContainerName}'!"); } return stream; } - public virtual Task GetOrNullAsync( + public virtual async Task GetOrNullAsync( string name, CancellationToken cancellationToken = default) { - return Provider.GetOrNullAsync( - new BlobProviderGetArgs( - ContainerName, - Configuration, - name, - GetTenantIdOrNull(), - CancellationTokenProvider.FallbackToProvider(cancellationToken) - ) - ); + using (CurrentTenant.Change(GetTenantIdOrNull())) + { + return await Provider.GetOrNullAsync( + new BlobProviderGetArgs( + ContainerName, + Configuration, + name, + CancellationTokenProvider.FallbackToProvider(cancellationToken) + ) + ); + } } - + protected virtual Guid? GetTenantIdOrNull() { if (!Configuration.IsMultiTenant) { return null; } - + return CurrentTenant.Id; } } diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderArgs.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderArgs.cs index e1ad228839..fcc264977a 100644 --- a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderArgs.cs +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderArgs.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading; +using System.Threading; using JetBrains.Annotations; namespace Volo.Abp.BlobStoring @@ -16,20 +15,16 @@ namespace Volo.Abp.BlobStoring public string BlobName { get; } public CancellationToken CancellationToken { get; } - - public Guid? TenantId { get; } protected BlobProviderArgs( [NotNull] string containerName, [NotNull] BlobContainerConfiguration configuration, [NotNull] string blobName, - [CanBeNull] Guid? tenantId = null, CancellationToken cancellationToken = default) { ContainerName = Check.NotNullOrWhiteSpace(containerName, nameof(containerName)); Configuration = Check.NotNull(configuration, nameof(configuration)); BlobName = Check.NotNullOrWhiteSpace(blobName, nameof(blobName)); - TenantId = tenantId; CancellationToken = cancellationToken; } } diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderDeleteArgs.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderDeleteArgs.cs index aa4aae1eb2..146074d444 100644 --- a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderDeleteArgs.cs +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderDeleteArgs.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading; +using System.Threading; using JetBrains.Annotations; namespace Volo.Abp.BlobStoring @@ -10,13 +9,11 @@ namespace Volo.Abp.BlobStoring [NotNull] string containerName, [NotNull] BlobContainerConfiguration configuration, [NotNull] string blobName, - [CanBeNull] Guid? tenantId = null, CancellationToken cancellationToken = default) : base( containerName, configuration, blobName, - tenantId, cancellationToken) { } diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderExistsArgs.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderExistsArgs.cs index a55b22a233..dee2e144f7 100644 --- a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderExistsArgs.cs +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderExistsArgs.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading; +using System.Threading; using JetBrains.Annotations; namespace Volo.Abp.BlobStoring @@ -10,13 +9,11 @@ namespace Volo.Abp.BlobStoring [NotNull] string containerName, [NotNull] BlobContainerConfiguration configuration, [NotNull] string blobName, - [CanBeNull] Guid? tenantId = null, CancellationToken cancellationToken = default) : base( containerName, configuration, blobName, - tenantId, cancellationToken) { } diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderGetArgs.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderGetArgs.cs index 94374698c7..f3087e9805 100644 --- a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderGetArgs.cs +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderGetArgs.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading; +using System.Threading; using JetBrains.Annotations; namespace Volo.Abp.BlobStoring @@ -10,13 +9,11 @@ namespace Volo.Abp.BlobStoring [NotNull] string containerName, [NotNull] BlobContainerConfiguration configuration, [NotNull] string blobName, - [CanBeNull] Guid? tenantId = null, CancellationToken cancellationToken = default) : base( containerName, configuration, blobName, - tenantId, cancellationToken) { } diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderSaveArgs.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderSaveArgs.cs index a81938fb7d..b8af43e4fd 100644 --- a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderSaveArgs.cs +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobProviderSaveArgs.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Threading; using JetBrains.Annotations; @@ -18,13 +17,11 @@ namespace Volo.Abp.BlobStoring [NotNull] string blobName, [NotNull] Stream blobStream, bool overrideExisting = false, - [CanBeNull] Guid? tenantId = null, CancellationToken cancellationToken = default) : base( containerName, configuration, blobName, - tenantId, cancellationToken) { BlobStream = Check.NotNull(blobStream, nameof(blobStream)); diff --git a/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs b/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs index cc68209790..b7382a7f59 100644 --- a/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs +++ b/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Shouldly; +using Volo.Abp.MultiTenancy; using Xunit; namespace Volo.Abp.BlobStoring.FileSystem @@ -8,10 +9,12 @@ namespace Volo.Abp.BlobStoring.FileSystem public class BlogFilePathCalculator_Tests : AbpBlobStoringFileSystemTestBase { private readonly IBlobFilePathCalculator _calculator; + private readonly ICurrentTenant _currentTenant; public BlogFilePathCalculator_Tests() { _calculator = GetRequiredService(); + _currentTenant = GetRequiredService(); } [Fact] @@ -30,9 +33,12 @@ namespace Volo.Abp.BlobStoring.FileSystem var separator = Path.DirectorySeparatorChar; var tenantId = Guid.NewGuid(); - _calculator.Calculate( - GetArgs($"C:{separator}my-files", "my-container", "my-blob", tenantId: tenantId) - ).ShouldBe($"C:{separator}my-files{separator}tenants{separator}{tenantId:D}{separator}my-container{separator}my-blob"); + using (_currentTenant.Change(tenantId)) + { + _calculator.Calculate( + GetArgs($"C:{separator}my-files", "my-container", "my-blob") + ).ShouldBe($"C:{separator}my-files{separator}tenants{separator}{tenantId:D}{separator}my-container{separator}my-blob"); + } } [Fact] @@ -49,7 +55,6 @@ namespace Volo.Abp.BlobStoring.FileSystem string basePath, string containerName, string blobName, - Guid? tenantId = null, bool? appendContainerNameToBasePath = null) { return new BlobProviderGetArgs( @@ -63,8 +68,7 @@ namespace Volo.Abp.BlobStoring.FileSystem fs.AppendContainerNameToBasePath = appendContainerNameToBasePath.Value; } }), - blobName, - tenantId + blobName ); } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs index 1d5cf50593..3edf68b053 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Threading; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; @@ -25,9 +24,9 @@ namespace Volo.Abp.BlobStoring.Database public override async Task SaveAsync(BlobProviderSaveArgs args) { - var container = await GetOrCreateContainerAsync(args.ContainerName, args.TenantId, args.CancellationToken); + var container = await GetOrCreateContainerAsync(args.ContainerName, args.CancellationToken); - var blob = await DatabaseBlobRepository.FindAsync(container.Id, args.BlobName, args.TenantId, + var blob = await DatabaseBlobRepository.FindAsync(container.Id, args.BlobName, args.CancellationToken); var content = await args.BlobStream.GetAllBytesAsync(args.CancellationToken); @@ -45,7 +44,7 @@ namespace Volo.Abp.BlobStoring.Database } else { - blob = new DatabaseBlob(GuidGenerator.Create(), container.Id, args.BlobName, content, args.TenantId); + blob = new DatabaseBlob(GuidGenerator.Create(), container.Id, args.BlobName, content); await DatabaseBlobRepository.InsertAsync(blob); } } @@ -53,7 +52,7 @@ namespace Volo.Abp.BlobStoring.Database public override async Task DeleteAsync(BlobProviderDeleteArgs args) { var container = - await DatabaseBlobContainerRepository.FindAsync(args.ContainerName, args.TenantId, + await DatabaseBlobContainerRepository.FindAsync(args.ContainerName, args.CancellationToken); if (container == null) @@ -61,14 +60,14 @@ namespace Volo.Abp.BlobStoring.Database return false; } - return await DatabaseBlobRepository.DeleteAsync(container.Id, args.BlobName, args.TenantId, + return await DatabaseBlobRepository.DeleteAsync(container.Id, args.BlobName, args.CancellationToken); } public override async Task ExistsAsync(BlobProviderExistsArgs args) { var container = - await DatabaseBlobContainerRepository.FindAsync(args.ContainerName, args.TenantId, + await DatabaseBlobContainerRepository.FindAsync(args.ContainerName, args.CancellationToken); if (container == null) @@ -76,14 +75,14 @@ namespace Volo.Abp.BlobStoring.Database return false; } - return await DatabaseBlobRepository.ExistsAsync(container.Id, args.BlobName, args.TenantId, + return await DatabaseBlobRepository.ExistsAsync(container.Id, args.BlobName, args.CancellationToken); } public override async Task GetOrNullAsync(BlobProviderGetArgs args) { var container = - await DatabaseBlobContainerRepository.FindAsync(args.ContainerName, args.TenantId, + await DatabaseBlobContainerRepository.FindAsync(args.ContainerName, args.CancellationToken); if (container == null) @@ -91,7 +90,7 @@ namespace Volo.Abp.BlobStoring.Database return null; } - var blob = await DatabaseBlobRepository.FindAsync(container.Id, args.BlobName, args.TenantId, + var blob = await DatabaseBlobRepository.FindAsync(container.Id, args.BlobName, args.CancellationToken); if (blob == null) @@ -104,16 +103,15 @@ namespace Volo.Abp.BlobStoring.Database protected virtual async Task GetOrCreateContainerAsync( string name, - Guid? tenantId = null, CancellationToken cancellationToken = default) { - var container = await DatabaseBlobContainerRepository.FindAsync(name, tenantId, cancellationToken); + var container = await DatabaseBlobContainerRepository.FindAsync(name, cancellationToken); if (container != null) { return container; } - container = new DatabaseBlobContainer(GuidGenerator.Create(), name, tenantId); + container = new DatabaseBlobContainer(GuidGenerator.Create(), name); await DatabaseBlobContainerRepository.InsertAsync(container, cancellationToken: cancellationToken); return container; diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobContainerRepository.cs index 34d94f5832..713d05ca11 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobContainerRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobContainerRepository.cs @@ -8,6 +8,6 @@ namespace Volo.Abp.BlobStoring.Database { public interface IDatabaseBlobContainerRepository : IBasicRepository { - Task FindAsync([NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); + Task FindAsync([NotNull] string name, CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobRepository.cs index 4f5097cae2..06afcfd28c 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IDatabaseBlobRepository.cs @@ -8,10 +8,10 @@ namespace Volo.Abp.BlobStoring.Database { public interface IDatabaseBlobRepository : IBasicRepository { - Task FindAsync(Guid containerId, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); + Task FindAsync(Guid containerId, [NotNull] string name, CancellationToken cancellationToken = default); - Task ExistsAsync(Guid containerId, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); + Task ExistsAsync(Guid containerId, [NotNull] string name, CancellationToken cancellationToken = default); - Task DeleteAsync(Guid containerId, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); + Task DeleteAsync(Guid containerId, [NotNull] string name, CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobContainerRepository.cs index fdcbad7de8..e1d0764807 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobContainerRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobContainerRepository.cs @@ -15,10 +15,9 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { } - public virtual async Task FindAsync(string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + public virtual async Task FindAsync(string name, CancellationToken cancellationToken = default) { - return await DbSet.WhereIf(tenantId != null, x => x.TenantId == tenantId) - .FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken)); + return await DbSet.FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken)); } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobRepository.cs index 95c4ae10c9..f4d1a83466 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobRepository.cs @@ -17,11 +17,10 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore public virtual async Task FindAsync( Guid containerId, string name, - Guid? tenantId = null, CancellationToken cancellationToken = default) { return await DbSet.FirstOrDefaultAsync( - x => x.ContainerId == containerId && x.Name == name && x.TenantId == tenantId, + x => x.ContainerId == containerId && x.Name == name, GetCancellationToken(cancellationToken) ); } @@ -29,23 +28,19 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore public virtual async Task ExistsAsync( Guid containerId, string name, - Guid? tenantId = null, CancellationToken cancellationToken = default) { return await DbSet.AnyAsync( - x => x.ContainerId == containerId && - x.Name == name && - x.TenantId == tenantId, + x => x.ContainerId == containerId && x.Name == name, GetCancellationToken(cancellationToken)); } public virtual async Task DeleteAsync( Guid containerId, string name, - Guid? tenantId = null, CancellationToken cancellationToken = default) { - var blob = await FindAsync(containerId, name, tenantId, cancellationToken); + var blob = await FindAsync(containerId, name, cancellationToken); if (blob == null) { return false; diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobContainerRepository.cs index 149835ab5a..9777b329f8 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobContainerRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobContainerRepository.cs @@ -13,9 +13,9 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB { } - public virtual async Task FindAsync(string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + public virtual async Task FindAsync(string name, CancellationToken cancellationToken = default) { - return await base.FindAsync(x => x.Name == name && x.TenantId == tenantId, cancellationToken: GetCancellationToken(cancellationToken)); + return await base.FindAsync(x => x.Name == name, cancellationToken: GetCancellationToken(cancellationToken)); } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobRepository.cs index b577df07a8..60d9e3d148 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobRepository.cs @@ -13,27 +13,25 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB { } - public virtual async Task FindAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + public virtual async Task FindAsync(Guid containerId, string name, CancellationToken cancellationToken = default) { return await GetMongoQueryable().FirstOrDefaultAsync( x => x.ContainerId == containerId && - x.Name == name && - x.TenantId == tenantId, + x.Name == name, GetCancellationToken(cancellationToken)); } - public virtual async Task ExistsAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + public virtual async Task ExistsAsync(Guid containerId, string name, CancellationToken cancellationToken = default) { return await GetMongoQueryable().AnyAsync( x => x.ContainerId == containerId && - x.Name == name && - x.TenantId == tenantId, + x.Name == name, GetCancellationToken(cancellationToken)); } - public virtual async Task DeleteAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(Guid containerId, string name, CancellationToken cancellationToken = default) { - var blob = await FindAsync(containerId, name, tenantId, cancellationToken); + var blob = await FindAsync(containerId, name, cancellationToken); if (blob == null) {