-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathUpdateTask.cs
More file actions
49 lines (41 loc) · 1.85 KB
/
UpdateTask.cs
File metadata and controls
49 lines (41 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Files Community
// Licensed under the MIT License.
using Files.App.Storage;
using System.IO;
using System.Threading.Tasks;
using Windows.ApplicationModel.Background;
using Windows.Storage;
namespace Files.App.BackgroundTasks
{
public sealed class UpdateTask : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance) => await RunAsync(taskInstance);
private async Task RunAsync(IBackgroundTaskInstance taskInstance)
{
var deferral = taskInstance.GetDeferral();
// Sync the jump list with Explorer
try { RefreshJumpList(); } catch { }
// Delete previous version log files
try { DeleteLogFiles(); } catch { }
deferral.Complete();
}
private void DeleteLogFiles()
{
File.Delete(Path.Combine(ApplicationData.Current.LocalFolder.Path, "debug.log"));
File.Delete(Path.Combine(ApplicationData.Current.LocalFolder.Path, "debug_fulltrust.log"));
}
private void RefreshJumpList()
{
// Make sure to delete the Files' custom destinations binary files
var recentFolder = WindowsStorableHelpers.GetRecentFolderPath();
File.Delete($"{recentFolder}\\CustomDestinations\\3b19d860a346d7da.customDestinations-ms");
File.Delete($"{recentFolder}\\CustomDestinations\\1265066178db259d.customDestinations-ms");
File.Delete($"{recentFolder}\\CustomDestinations\\8e2322986488aba5.customDestinations-ms");
File.Delete($"{recentFolder}\\CustomDestinations\\6b0bf5ca007c8bea.customDestinations-ms");
File.Delete($"{recentFolder}\\AutomaticDestinations\\3b19d860a346d7da.automaticDestinations-ms");
File.Delete($"{recentFolder}\\AutomaticDestinations\\1265066178db259d.automaticDestinations-ms");
File.Delete($"{recentFolder}\\AutomaticDestinations\\8e2322986488aba5.automaticDestinations-ms");
File.Delete($"{recentFolder}\\AutomaticDestinations\\6b0bf5ca007c8bea.automaticDestinations-ms");
}
}
}