Skip to content

Commit 1a54340

Browse files
committed
Added EF migration code that sets IsTransient = true to false (to prevent deletion of transient media files after TransientMediaClearTask gets enabled again)
1 parent 246beb2 commit 1a54340

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Libraries/SmartStore.Data/Migrations/201603121451066_ThirdPartyEmailHandOver.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace SmartStore.Data.Migrations
22
{
33
using System.Data.Entity.Migrations;
4-
using Setup;
4+
using SmartStore.Data.Setup;
5+
using SmartStore.Core.Domain.Media;
6+
using System.Linq;
57

68
public partial class ThirdPartyEmailHandOver : DbMigration, ILocaleResourcesProvider, IDataSeeder<SmartObjectContext>
79
{
@@ -23,6 +25,17 @@ public bool RollbackOnFailure
2325
public void Seed(SmartObjectContext context)
2426
{
2527
context.MigrateLocaleResources(MigrateLocaleResources);
28+
29+
// Some users have disabled the "TransientMediaClearTask" due to a bug.
30+
// When the task is enabled again, it would delete media files, which are marked as transient
31+
// but are permanent actually. To avoid this, we have to set IsTransient to false.
32+
var transientPictures = context.Set<Picture>().Where(x => x.IsTransient == true).ToList();
33+
transientPictures.Each(x => x.IsTransient = false);
34+
35+
var transientDownloads = context.Set<Download>().Where(x => x.IsTransient == true).ToList();
36+
transientDownloads.Each(x => x.IsTransient = false);
37+
38+
context.SaveChanges();
2639
}
2740

2841
public void MigrateLocaleResources(LocaleResourcesBuilder builder)

0 commit comments

Comments
 (0)