void FullRefresh(Folder folder, MetadataRefreshOptions options) { Kernel.Instance.MajorActivity = true; Information.AddInformationString(CurrentInstance.StringData("FullRefreshMsg")); folder.RefreshMetadata(options); using (new Profiler(CurrentInstance.StringData("FullValidationProf"))) { RunActionRecursively(folder, item => { Folder f = item as Folder; if (f != null) f.ValidateChildren(); }); } using (new Profiler(CurrentInstance.StringData("FastRefreshProf"))) { RunActionRecursively(folder, item => item.RefreshMetadata(MetadataRefreshOptions.FastOnly)); } using (new Profiler(CurrentInstance.StringData("SlowRefresh"))) { RunActionRecursively(folder, item => item.RefreshMetadata(MetadataRefreshOptions.Default)); } Information.AddInformationString(CurrentInstance.StringData("FullRefreshFinishedMsg")); Kernel.Instance.MajorActivity = false; }
static void FullRefresh(Folder folder, MetadataRefreshOptions options) { int totalItems = 0; int fastMetadataChanged = 0; int slowMetadataChanged = 0; folder.RefreshMetadata(options); Console.Out.WriteLine(); Console.Out.WriteLine("===[Validate]============================================"); Console.Out.WriteLine(); var validationTime = TimeAction(() => { RunActionRecursively("validate", folder, item => { Folder f = item as Folder; if (f != null) f.ValidateChildren(); }); }); Console.Out.WriteLine(); Console.Out.WriteLine("===[Fast Metadata]======================================="); Console.Out.WriteLine(); var fastMetadataTime = TimeAction(() => { RunActionRecursively("fast metadata", folder, item => { fastMetadataChanged += item.RefreshMetadata(MetadataRefreshOptions.FastOnly) ? 1 : 0; totalItems++; }); }); if (rebuildImageCache) { Console.Out.WriteLine(); Console.Out.WriteLine("===[Recreate ImageCache]================================="); Console.Out.WriteLine(); Console.Out.WriteLine("/i specified - Clearing Image Cache for re-build.."); Console.Out.WriteLine(); try { Console.Out.WriteLine("Deleting ImageCache folder."); Directory.Delete(ApplicationPaths.AppImagePath, true); } catch (Exception ex) { Console.Out.WriteLine("Error trying to delete ImageCache folder. " + ex.Message); } Console.Out.WriteLine("Sleeping 2 seconds."); System.Threading.Thread.Sleep(2000); // give it time to fully delete Console.Out.WriteLine("Continuing."); try { Console.Out.WriteLine("Creating ImageCache folder."); Directory.CreateDirectory(ApplicationPaths.AppImagePath); } catch (Exception ex) { Console.Out.WriteLine("Error trying to create ImageCache folder. " + ex.Message); } Console.Out.WriteLine("Sleeping 2 seconds."); System.Threading.Thread.Sleep(2000); // give it time to fully create Console.Out.WriteLine("Continuing."); } Console.Out.WriteLine(); Console.Out.WriteLine("===[Slow Metadata]======================================="); Console.Out.WriteLine(); var slowMetadataTime = TimeAction(() => { RunActionRecursively("slow metadata", folder, item => { slowMetadataChanged += item.RefreshMetadata(MetadataRefreshOptions.Default) ? 1 : 0; if (rebuildImageCache) { //touch all the images - causing them to be re-cached Console.Out.WriteLine("Caching images for " + item.Name); string ignore = null; if (item.PrimaryImage != null) ignore = item.PrimaryImage.GetLocalImagePath(); if (item.SecondaryImage != null) ignore = item.SecondaryImage.GetLocalImagePath(); if (item.BackdropImages != null) foreach (var image in item.BackdropImages) { ignore = image.GetLocalImagePath(); } if (item.BannerImage != null) ignore = item.BannerImage.GetLocalImagePath(); } }); }); Console.Out.WriteLine(); Console.Out.WriteLine("===[Saving LastFullRefresh]=============================="); Console.Out.WriteLine(); Console.Out.WriteLine("Saving LastFullRefresh in config"); Kernel.Instance.ConfigData.LastFullRefresh = DateTime.Now; Kernel.Instance.ConfigData.Save(); Console.Out.WriteLine(); Console.Out.WriteLine("===[Results]============================================="); Console.Out.WriteLine(); Console.Out.WriteLine("We are done"); Console.Out.WriteLine(); Console.Out.WriteLine("Validation took: " + (new DateTime(validationTime.Ticks)).ToString("HH:mm:ss")); Console.Out.WriteLine("Fast metadata took: " + (new DateTime(fastMetadataTime.Ticks)).ToString("HH:mm:ss")); Console.Out.WriteLine("Slow metadata took: " + (new DateTime(slowMetadataTime.Ticks)).ToString("HH:mm:ss")); Console.Out.WriteLine("Total items in your library: {0}", totalItems); Console.Out.WriteLine(); Console.Out.WriteLine("Fast metadata changed on {0} item's", fastMetadataChanged); Console.Out.WriteLine("Slow metadata changed on {0} item's", slowMetadataChanged); Console.Out.WriteLine(); Console.Out.WriteLine("===[EOF]=================================================="); }