diff --git a/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs b/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs index 99efc7cb6a..9176a8d328 100644 --- a/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs @@ -21,17 +21,20 @@ namespace Umbraco.Web.Cache Member.BeforeDelete += MemberBeforeDelete; MediaService.Saved += MediaServiceSaved; + //We need to perform all of the 'before' events here because we need a reference to the + //media item's Path before it is moved/deleting/trashed + //see: http://issues.umbraco.org/issue/U4-1653 MediaService.Deleting += MediaServiceDeleting; - MediaService.Moved += MediaServiceMoved; - MediaService.Trashed += MediaService_Trashed; + MediaService.Moving += MediaServiceMoving; + MediaService.Trashing += MediaServiceTrashing; } - static void MediaService_Trashed(IMediaService sender, Core.Events.MoveEventArgs e) + static void MediaServiceTrashing(IMediaService sender, Core.Events.MoveEventArgs e) { ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(e.Entity.Id); } - static void MediaServiceMoved(IMediaService sender, Core.Events.MoveEventArgs e) + static void MediaServiceMoving(IMediaService sender, Core.Events.MoveEventArgs e) { ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(e.Entity.Id); } @@ -44,15 +47,6 @@ namespace Umbraco.Web.Cache } } - //NOTE: this should not need to be done, the SavedCollection event shouldn't even exist!! :( - static void MediaServiceSavedCollection(IMediaService sender, Core.Events.SaveEventArgs> e) - { - foreach (var item in e.SavedEntities.SelectMany(x => x)) - { - ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(item.Id); - } - } - static void MediaServiceSaved(IMediaService sender, Core.Events.SaveEventArgs e) { foreach (var item in e.SavedEntities)