|
1 | 1 | using System; |
2 | 2 | using System.Text; |
3 | | -using GeneralUpdate.Core.FileSystem; |
4 | 3 |
|
5 | 4 | namespace GeneralUpdate.Core.Configuration |
6 | 5 | { |
7 | 6 | /// <summary> |
8 | | - /// Convenience accessor for UpdateOption constants. |
| 7 | + /// Framework-level update option constants. |
9 | 8 | /// Each option has a unique string name and a reasonable default value. |
10 | | - /// Use via <c>.Option(UpdateOptions.UpdateUrl, "https://...")</c>. |
| 9 | + /// Business-specific configuration (URLs, keys, app names, etc.) belongs in |
| 10 | + /// <see cref="Configinfo"/> / <see cref="BaseConfigInfo"/>. |
11 | 11 | /// </summary> |
12 | 12 | public static class UpdateOptions |
13 | 13 | { |
14 | 14 | // ═══ Core ═══ |
| 15 | + /// <summary>Application role type — Client, Upgrade, or OSS.</summary> |
15 | 16 | public static UpdateOption<AppType> AppType { get; } = UpdateOption.ValueOf<AppType>("APPTYPE", Configuration.AppType.Client); |
16 | 17 |
|
17 | 18 | // ═══ Diff mode ═══ |
| 19 | + /// <summary>Diff/patch generation mode — Serial or Parallel.</summary> |
18 | 20 | public static UpdateOption<DiffMode> DiffMode { get; } = UpdateOption.ValueOf<DiffMode>("DIFFMODE", Configuration.DiffMode.Serial); |
19 | 21 |
|
20 | 22 | // ═══ Backward-compatible options ═══ |
| 23 | + /// <summary>Compression encoding for update packages.</summary> |
21 | 24 | public static UpdateOption<Encoding> Encoding { get; } = UpdateOption.ValueOf<Encoding>("COMPRESSENCODING", System.Text.Encoding.UTF8); |
| 25 | + |
| 26 | + /// <summary>Compression format (e.g., "ZIP").</summary> |
22 | 27 | public static UpdateOption<string> Format { get; } = UpdateOption.ValueOf<string>("COMPRESSFORMAT", "ZIP"); |
| 28 | + |
| 29 | + /// <summary>Download timeout in seconds.</summary> |
23 | 30 | public static UpdateOption<int?> DownloadTimeout { get; } = UpdateOption.ValueOf<int?>("DOWNLOADTIMEOUT", 30); |
| 31 | + |
| 32 | + /// <summary>Whether driver update mode is enabled.</summary> |
24 | 33 | public static UpdateOption<bool?> DriveEnabled { get; } = UpdateOption.ValueOf<bool?>("DRIVE", false); |
| 34 | + |
| 35 | + /// <summary>Whether differential patch update is enabled.</summary> |
25 | 36 | public static UpdateOption<bool?> PatchEnabled { get; } = UpdateOption.ValueOf<bool?>("PATCH", true); |
| 37 | + |
| 38 | + /// <summary>Whether backup before update is enabled.</summary> |
26 | 39 | public static UpdateOption<bool?> BackupEnabled { get; } = UpdateOption.ValueOf<bool?>("BACKUP", true); |
| 40 | + |
| 41 | + /// <summary>Update mode override.</summary> |
27 | 42 | public static UpdateOption<UpdateMode?> Mode { get; } = UpdateOption.ValueOf<UpdateMode?>("MODE", null); |
| 43 | + |
| 44 | + /// <summary>Whether silent background update is enabled.</summary> |
28 | 45 | public static UpdateOption<bool> Silent { get; } = UpdateOption.ValueOf<bool>("ENABLESILENTUPDATE", false); |
29 | 46 |
|
30 | | - // ═══ New options ═══ |
31 | | - public static UpdateOption<string?> UpdateUrl { get; } = UpdateOption.ValueOf<string?>("UPDATEURL", null); |
32 | | - public static UpdateOption<string> AppSecretKey { get; } = UpdateOption.ValueOf<string>("APPSECRETKEY", string.Empty); |
33 | | - public static UpdateOption<string> AppName { get; } = UpdateOption.ValueOf<string>("APPNAME", string.Empty); |
34 | | - public static UpdateOption<string> MainAppName { get; } = UpdateOption.ValueOf<string>("MAINAPPNAME", string.Empty); |
35 | | - public static UpdateOption<string> InstallPath { get; } = UpdateOption.ValueOf<string>("INSTALLPATH", AppContext.BaseDirectory); |
36 | | - public static UpdateOption<string> ClientVersion { get; } = UpdateOption.ValueOf<string>("CLIENTVERSION", string.Empty); |
37 | | - public static UpdateOption<string?> UpgradeClientVersion { get; } = UpdateOption.ValueOf<string?>("UPGRADECLIENTVERSION", null); |
38 | | - public static UpdateOption<PlatformType?> Platform { get; } = UpdateOption.ValueOf<PlatformType?>("PLATFORM", null); |
| 47 | + // ═══ Silent mode ═══ |
| 48 | + /// <summary>Whether silent updates auto-install without user intervention.</summary> |
39 | 49 | public static UpdateOption<bool> SilentAutoInstall { get; } = UpdateOption.ValueOf<bool>("SILENTAUTOINSTALL", false); |
| 50 | + |
| 51 | + /// <summary>Polling interval in minutes for silent update checks.</summary> |
40 | 52 | public static UpdateOption<int> SilentPollIntervalMinutes { get; } = UpdateOption.ValueOf<int>("SILENTPOLLINTERVALMINUTES", 60); |
| 53 | + |
| 54 | + // ═══ Concurrency & Resume ═══ |
| 55 | + /// <summary>Maximum concurrent download operations.</summary> |
41 | 56 | public static UpdateOption<int> MaxConcurrency { get; } = UpdateOption.ValueOf<int>("MAXCONCURRENCY", 3); |
| 57 | + |
| 58 | + /// <summary>Whether download resume is enabled.</summary> |
42 | 59 | public static UpdateOption<bool> EnableResume { get; } = UpdateOption.ValueOf<bool>("ENABLERESUME", true); |
| 60 | + |
| 61 | + // ═══ Resilience ═══ |
| 62 | + /// <summary>Number of retry attempts for failed operations.</summary> |
43 | 63 | public static UpdateOption<int> RetryCount { get; } = UpdateOption.ValueOf<int>("RETRYCOUNT", 3); |
| 64 | + |
| 65 | + /// <summary>Whether checksum verification is performed after download.</summary> |
44 | 66 | public static UpdateOption<bool> VerifyChecksum { get; } = UpdateOption.ValueOf<bool>("VERIFYCHECKSUM", true); |
45 | | - public static UpdateOption<string?> ReportUrl { get; } = UpdateOption.ValueOf<string?>("REPORTURL", null); |
46 | | - public static UpdateOption<string?> ProductId { get; } = UpdateOption.ValueOf<string?>("PRODUCTID", null); |
47 | | - public static UpdateOption<string?> PermissionScript { get; } = UpdateOption.ValueOf<string?>("PERMISSIONSCRIPT", null); |
48 | | - public static UpdateOption<string?> Scheme { get; } = UpdateOption.ValueOf<string?>("SCHEME", null); |
49 | | - public static UpdateOption<string?> Token { get; } = UpdateOption.ValueOf<string?>("TOKEN", null); |
| 67 | + |
| 68 | + /// <summary>Initial retry interval for exponential back-off. Default 1 second.</summary> |
| 69 | + public static UpdateOption<TimeSpan> RetryInterval { get; } = UpdateOption.ValueOf<TimeSpan>("RETRYINTERVAL", TimeSpan.FromSeconds(1)); |
50 | 70 |
|
51 | 71 | // ═══ OSS ═══ |
| 72 | + /// <summary>Object Storage Service provider type.</summary> |
52 | 73 | public static UpdateOption<OssProvider?> OSSProvider { get; } = UpdateOption.ValueOf<OssProvider?>("OSSPROVIDER", null); |
| 74 | + |
| 75 | + /// <summary>OSS bucket region identifier.</summary> |
53 | 76 | public static UpdateOption<string?> OSSBucketRegion { get; } = UpdateOption.ValueOf<string?>("OSSBUCKETREGION", null); |
54 | 77 |
|
55 | 78 | // ═══ Blacklist ═══ |
| 79 | + /// <summary>Blacklist configuration for files and directories to exclude from updates.</summary> |
56 | 80 | public static UpdateOption<BlackListConfig> BlackList { get; } = UpdateOption.ValueOf<BlackListConfig>("BLACKLIST", BlackListConfig.Empty); |
57 | 81 |
|
58 | | - // ═══ Watchdog ═══ |
59 | | - /// <summary>Bowl (crash monitor / watchdog) executable path.</summary> |
60 | | - public static UpdateOption<string?> Bowl { get; } = UpdateOption.ValueOf<string?>("BOWL", null); |
61 | | - |
62 | | - // ═══ Logging & Script ═══ |
63 | | - /// <summary>Remote update log / changelog URL.</summary> |
64 | | - public static UpdateOption<string?> UpdateLogUrl { get; } = UpdateOption.ValueOf<string?>("UPDATELOGURL", null); |
65 | | - /// <summary>Custom execution script path for pre/post-update actions.</summary> |
66 | | - public static UpdateOption<string?> Script { get; } = UpdateOption.ValueOf<string?>("SCRIPT", null); |
67 | | - |
68 | | - // ═══ Retry ═══ |
69 | | - /// <summary>Initial retry interval for exponential backoff. Default 1 second.</summary> |
70 | | - public static UpdateOption<TimeSpan> RetryInterval { get; } = UpdateOption.ValueOf<TimeSpan>("RETRYINTERVAL", TimeSpan.FromSeconds(1)); |
71 | | - |
72 | 82 | // ═══ SignalR Hub ═══ |
73 | 83 | /// <summary>SignalR Hub configuration for push-based updates.</summary> |
74 | 84 | public static UpdateOption<HubConfig?> Hub { get; } = UpdateOption.ValueOf<HubConfig?>("HUB", null); |
|
0 commit comments