Browse Source

fix delete order

- local file should be removed first
pull/296/head
razims 8 years ago
parent
commit
8a2716a848
  1. 9
      src/Squidex.Infrastructure.MongoGridFs/Assets/MongoGridFsAssetStore.cs

9
src/Squidex.Infrastructure.MongoGridFs/Assets/MongoGridFsAssetStore.cs

@ -141,16 +141,13 @@ namespace Squidex.Infrastructure.Assets
{
try
{
var filter =
Builders<GridFSFileInfo>.Filter.And(
file.Delete();
using (var cursor = await bucket.FindAsync(Builders<GridFSFileInfo>.Filter.And(
Builders<GridFSFileInfo>.Filter.Eq(x => x.Filename, file.Name)
);
using (var cursor = await bucket.FindAsync(filter))
)))
{
await cursor.ForEachAsync(fileInfo => bucket.DeleteAsync(fileInfo.Id));
}
file.Delete();
}
catch (FileNotFoundException ex)
{

Loading…
Cancel
Save