Skip to content

Commit 6ceb8ae

Browse files
committed
screenshot updates
1 parent 2e7779b commit 6ceb8ae

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Models/WatchLocation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ internal sealed class WatchLocation
99
public Guid SaveGameId { get; set; }
1010
public string Location { get; set; }
1111
public string GameDirectory { get; set; }
12+
public bool IsTakingScreenshot { get; set; }
1213
}

Services/ScreenshotService.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,20 @@ private void OnChanged(object sender, FileSystemEventArgs args)
195195

196196
if (_watchers.TryGetValue(directory, out WatchLocation watchLocation))
197197
{
198-
string saveDirectory = Path.Combine(_config.BackupsDirectory, watchLocation.SaveGameId.ToString());
199-
TakeScreenshot(saveDirectory, watchLocation.GameDirectory);
198+
if (!watchLocation.IsTakingScreenshot)
199+
{
200+
watchLocation.IsTakingScreenshot = true;
201+
202+
try
203+
{
204+
string saveDirectory = Path.Combine(_config.BackupsDirectory, watchLocation.SaveGameId.ToString());
205+
TakeScreenshot(saveDirectory, watchLocation.GameDirectory);
206+
}
207+
finally
208+
{
209+
watchLocation.IsTakingScreenshot = false;
210+
}
211+
}
200212
}
201213
}
202214
}
@@ -281,13 +293,7 @@ private void TakeLinuxScreenshot(string saveDirectory)
281293

282294
if (File.Exists(savePath))
283295
{
284-
_loggingService.LogInfo("Old Screenshot exists - attempting delete");
285296
File.Delete(savePath);
286-
_loggingService.LogInfo($"Old Screenshot deleted: {!File.Exists(savePath)}");
287-
}
288-
else
289-
{
290-
_loggingService.LogInfo("Old Screenshot does not exist.");
291297
}
292298

293299
string arguments = _isInFlatpak

0 commit comments

Comments
 (0)