Skip to content

Commit 7a43035

Browse files
committed
Fix issue when resetting desktop wallpaper
1 parent d841171 commit 7a43035

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/EventScheduler.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public bool Run(bool forceImageUpdate = false, DisplayEvent overrideEvent = null
101101
SolarScheduler.CalcNextUpdateTime(data, displayEvents[i]);
102102
LoggingHandler.LogMessage("Updated display event: {0}", displayEvents[i]);
103103

104-
bool isEventOverridden = displayEvents[i].displayIndex == overrideEvent?.displayIndex;
104+
bool isEventOverridden = overrideEvent != null &&
105+
displayEvents[i].displayIndex == Math.Max(0, overrideEvent.displayIndex);
105106
if (displayEvents[i].currentTheme != null || isEventOverridden)
106107
{
107108
HandleDisplayEvent(isEventOverridden ? overrideEvent : displayEvents[i]);
@@ -238,15 +239,6 @@ private void HandleTimerEvent(bool updateLocation)
238239
}
239240

240241
UpdateChecker.TryCheckAuto();
241-
// Update access time for extracted DLL files to prevent Storage Sense from deleting them
242-
string tempLibPath = Path.Combine(Path.GetTempPath(), ".net", Application.ProductName);
243-
if (Directory.Exists(tempLibPath))
244-
{
245-
foreach (string filePath in Directory.EnumerateFiles(tempLibPath, "*.dll", SearchOption.AllDirectories))
246-
{
247-
File.SetLastAccessTime(filePath, DateTime.Now);
248-
}
249-
}
250242
}
251243

252244
private void OnBackgroundTimerElapsed(object sender, EventArgs e)

src/UpdateChecker.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using RestSharp;
66
using System;
77
using System.Globalization;
8+
using System.IO;
89
using System.Reflection;
910
using System.Runtime.InteropServices;
1011
using System.Threading.Tasks;
@@ -136,6 +137,7 @@ private static async Task CheckAuto()
136137

137138
public static void TryCheckAuto(bool forceIfEnabled = false)
138139
{
140+
PreserveTempDlls();
139141
if (UwpDesktop.IsRunningAsUwp() || JsonConfig.settings.autoUpdateCheck == false)
140142
{
141143
return;
@@ -156,6 +158,19 @@ public static void TryCheckAuto(bool forceIfEnabled = false)
156158
Task.Run(CheckAuto);
157159
}
158160

161+
private static void PreserveTempDlls()
162+
{
163+
// Update access time for extracted DLL files to prevent Storage Sense from deleting them
164+
string tempLibPath = Path.Combine(Path.GetTempPath(), ".net", Application.ProductName);
165+
if (Directory.Exists(tempLibPath))
166+
{
167+
foreach (string filePath in Directory.EnumerateFiles(tempLibPath, "*.dll", SearchOption.AllDirectories))
168+
{
169+
File.SetLastAccessTime(filePath, DateTime.Now);
170+
}
171+
}
172+
}
173+
159174
private static void OnAutoUpdateItemClick(object sender, EventArgs e)
160175
{
161176
bool isEnabled = JsonConfig.settings.autoUpdateCheck ^ true;

0 commit comments

Comments
 (0)