forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMigrations.cs
More file actions
61 lines (57 loc) · 2.35 KB
/
Migrations.cs
File metadata and controls
61 lines (57 loc) · 2.35 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
50
51
52
53
54
55
56
57
58
59
60
61
using System.Application.Services;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace System.Application
{
/// <summary>
/// 新版本破坏性更改迁移
/// </summary>
public static class Migrations
{
static Version? PreviousVersion { get; } = Version.TryParse(VersionTracking2.PreviousVersion, out var value) ? value : null;
/// <summary>
/// 开始迁移(在 DI 初始化完毕后调用)
/// </summary>
public static void Up()
{
// 可以删除 /AppData/application2.dbf 表 0984415E 使此 if 返回 True
// 目前此数据库中仅有这一张表,所以可以直接删除文件,但之后可能会新增新表
if (VersionTracking2.IsFirstLaunchForCurrentVersion) // 当前版本号第一次启动
{
if (PreviousVersion != null) // 上一次运行的版本小于 2.6.2 时将执行以下迁移
{
if (PreviousVersion < new Version(2, 6, 2))
{
try
{
var cacheScript = Path.Combine(IOPath.CacheDirectory, IScriptManager.DirName);
if (Directory.Exists(cacheScript))
Directory.Delete(cacheScript, true);
}
catch (Exception e)
{
Log.Error(nameof(Migrations), e, "RemoveJSCache");
}
}
if (OperatingSystem2.IsWindows() &&
!DesktopBridge.IsRunningAsUwp &&
PreviousVersion < new Version(2, 7, 3)) // 上一次运行的版本小于 2.7.3 时将执行以下迁移
{
try
{
var binPath = Path.Combine(AppContext.BaseDirectory, "Bin");
if (Directory.Exists(binPath))
Directory.Delete(binPath, true);
}
catch (Exception e)
{
Log.Error(nameof(Migrations), e, "RemovebinPath");
}
}
}
}
}
}
}