mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Workshop - Auto-updating WIP
This commit is contained in:
1 parent
99d11e1921
commit
3b2d799bfc
18 files changed
+379
-108
No files matched your search
@@ -26,4 +26,10 @@ public class EntryInstallResult
|
||||
Entry = installedEntry
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(IsSuccess)}: {IsSuccess}, {nameof(Message)}: {Message}";
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -30,7 +30,7 @@ public class PluginEntryInstallationHandler : IEntryInstallationHandler
|
||||
{
|
||||
// If the folder already exists, we're not going to reinstall the plugin since files may be in use, consider our job done
|
||||
if (installedEntry.GetReleaseDirectory(release).Exists)
|
||||
return EntryInstallResult.FromSuccess(installedEntry);
|
||||
return ApplyAndSave(installedEntry, release);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -102,10 +102,7 @@ public class PluginEntryInstallationHandler : IEntryInstallationHandler
|
||||
return EntryInstallResult.FromFailure(e.Message);
|
||||
}
|
||||
|
||||
installedEntry.ApplyRelease(release);
|
||||
|
||||
_workshopService.SaveInstalledEntry(installedEntry);
|
||||
return EntryInstallResult.FromSuccess(installedEntry);
|
||||
return ApplyAndSave(installedEntry, release);
|
||||
}
|
||||
|
||||
public Task<EntryUninstallResult> UninstallAsync(InstalledEntry installedEntry, CancellationToken cancellationToken)
|
||||
@@ -135,4 +132,11 @@ public class PluginEntryInstallationHandler : IEntryInstallationHandler
|
||||
_workshopService.RemoveInstalledEntry(installedEntry);
|
||||
return Task.FromResult(EntryUninstallResult.FromSuccess(message));
|
||||
}
|
||||
|
||||
private EntryInstallResult ApplyAndSave(InstalledEntry installedEntry, IRelease release)
|
||||
{
|
||||
installedEntry.ApplyRelease(release);
|
||||
_workshopService.SaveInstalledEntry(installedEntry);
|
||||
return EntryInstallResult.FromSuccess(installedEntry);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,9 @@ public class InstalledEntry : CorePropertyChanged, IEntrySummary
|
||||
private DateTimeOffset _createdAt;
|
||||
private long? _latestReleaseId;
|
||||
private IReadOnlyList<IGetDependantEntries_Entries_Items_Categories> _categories;
|
||||
private long _releaseId;
|
||||
private string _releaseVersion = string.Empty;
|
||||
private bool _autoUpdate;
|
||||
|
||||
internal InstalledEntry(EntryEntity entity)
|
||||
{
|
||||
@@ -36,12 +39,26 @@ public class InstalledEntry : CorePropertyChanged, IEntrySummary
|
||||
AutoUpdate = true;
|
||||
}
|
||||
|
||||
public long ReleaseId { get; set; }
|
||||
public string ReleaseVersion { get; set; } = string.Empty;
|
||||
public DateTimeOffset InstalledAt { get; set; }
|
||||
public bool AutoUpdate { get; set; }
|
||||
|
||||
internal EntryEntity Entity { get; }
|
||||
public DateTimeOffset InstalledAt { get; set; }
|
||||
|
||||
public long ReleaseId
|
||||
{
|
||||
get => _releaseId;
|
||||
set => SetAndNotify(ref _releaseId, value);
|
||||
}
|
||||
|
||||
public string ReleaseVersion
|
||||
{
|
||||
get => _releaseVersion;
|
||||
set => SetAndNotify(ref _releaseVersion, value);
|
||||
}
|
||||
|
||||
public bool AutoUpdate
|
||||
{
|
||||
get => _autoUpdate;
|
||||
set => SetAndNotify(ref _autoUpdate, value);
|
||||
}
|
||||
|
||||
internal void Load()
|
||||
{
|
||||
@@ -233,4 +250,10 @@ public class InstalledEntry : CorePropertyChanged, IEntrySummary
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{EntryType}] {Id} - {Name}";
|
||||
}
|
||||
}
|
||||
@@ -32,4 +32,12 @@ query GetEntrySummaryById($id: Long!) {
|
||||
entry(id: $id) {
|
||||
...entrySummary
|
||||
}
|
||||
}
|
||||
|
||||
query GetEntryLatestReleaseById($id: Long!) {
|
||||
entry(id: $id) {
|
||||
latestRelease {
|
||||
...releaseDetails
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,5 +133,6 @@ public interface IWorkshopService
|
||||
public event EventHandler<InstalledEntry>? OnInstalledEntrySaved;
|
||||
public event EventHandler<InstalledEntry>? OnEntryUninstalled;
|
||||
public event EventHandler<InstalledEntry>? OnEntryInstalled;
|
||||
|
||||
|
||||
void SetAutoUpdate(InstalledEntry installedEntry, bool autoUpdate);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class WorkshopService : IWorkshopService
|
||||
if (result.IsSuccess && result.Entry != null)
|
||||
OnEntryInstalled?.Invoke(this, result.Entry);
|
||||
else
|
||||
_logger.Warning("Failed to install entry {EntryId}: {Message}", entry.Id, result.Message);
|
||||
_logger.Warning("Failed to install entry {Entry}: {Message}", entry, result.Message);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -254,6 +254,16 @@ public class WorkshopService : IWorkshopService
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetAutoUpdate(InstalledEntry installedEntry, bool autoUpdate)
|
||||
{
|
||||
if (installedEntry.AutoUpdate == autoUpdate)
|
||||
return;
|
||||
|
||||
installedEntry.AutoUpdate = autoUpdate;
|
||||
SaveInstalledEntry(installedEntry);
|
||||
}
|
||||
|
||||
private void RemoveOrphanedFiles()
|
||||
{
|
||||
List<InstalledEntry> entries = GetInstalledEntries();
|
||||
@@ -308,6 +318,8 @@ public class WorkshopService : IWorkshopService
|
||||
}
|
||||
|
||||
public event EventHandler<InstalledEntry>? OnInstalledEntrySaved;
|
||||
|
||||
public event EventHandler<InstalledEntry>? OnEntryUninstalled;
|
||||
|
||||
public event EventHandler<InstalledEntry>? OnEntryInstalled;
|
||||
}
|
||||
Reference in new issue
Block a user