|
|
|
@ -15,35 +15,41 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB
|
|
|
|
|
|
|
|
|
|
public virtual async Task<DatabaseBlob> FindAsync(Guid containerId, string name, CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
|
|
|
|
return await GetMongoQueryable().FirstOrDefaultAsync(
|
|
|
|
|
x => x.ContainerId == containerId &&
|
|
|
|
|
x.Name == name,
|
|
|
|
|
GetCancellationToken(cancellationToken));
|
|
|
|
|
cancellationToken = GetCancellationToken(cancellationToken);
|
|
|
|
|
|
|
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken))
|
|
|
|
|
.FirstOrDefaultAsync(
|
|
|
|
|
x => x.ContainerId == containerId && x.Name == name,
|
|
|
|
|
cancellationToken
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task<bool> ExistsAsync(Guid containerId, string name, CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
|
|
|
|
return await GetMongoQueryable().AnyAsync(
|
|
|
|
|
x => x.ContainerId == containerId &&
|
|
|
|
|
x.Name == name,
|
|
|
|
|
GetCancellationToken(cancellationToken));
|
|
|
|
|
cancellationToken = GetCancellationToken(cancellationToken);
|
|
|
|
|
|
|
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken))
|
|
|
|
|
.AnyAsync(
|
|
|
|
|
x => x.ContainerId == containerId && x.Name == name,
|
|
|
|
|
cancellationToken
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task<bool> DeleteAsync(
|
|
|
|
|
Guid containerId,
|
|
|
|
|
Guid containerId,
|
|
|
|
|
string name,
|
|
|
|
|
bool autoSave = false,
|
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
|
|
|
|
var blob = await FindAsync(containerId, name, cancellationToken);
|
|
|
|
|
|
|
|
|
|
if (blob == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await base.DeleteAsync(blob, autoSave, cancellationToken: GetCancellationToken(cancellationToken));
|
|
|
|
|
await base.DeleteAsync(blob, autoSave, cancellationToken);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|