diff --git a/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs b/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs index f45ac5327..64f476c51 100644 --- a/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs +++ b/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs @@ -14,6 +14,7 @@ public class EntryEntity public int EntryType { get; set; } public string Author { get; set; } = string.Empty; + public bool IsOfficial { get; set; } public string Name { get; set; } = string.Empty; public string Summary { get; set; } = string.Empty; public long Downloads { get; set; } diff --git a/src/Artemis.Storage/Migrations/20240706131336_ExpandInstalledEntry.Designer.cs b/src/Artemis.Storage/Migrations/20240722084220_AutoUpdating.Designer.cs similarity index 98% rename from src/Artemis.Storage/Migrations/20240706131336_ExpandInstalledEntry.Designer.cs rename to src/Artemis.Storage/Migrations/20240722084220_AutoUpdating.Designer.cs index 47d82c429..588333d41 100644 --- a/src/Artemis.Storage/Migrations/20240706131336_ExpandInstalledEntry.Designer.cs +++ b/src/Artemis.Storage/Migrations/20240722084220_AutoUpdating.Designer.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Artemis.Storage.Migrations { [DbContext(typeof(ArtemisDbContext))] - [Migration("20240706131336_ExpandInstalledEntry")] - partial class ExpandInstalledEntry + [Migration("20240722084220_AutoUpdating")] + partial class AutoUpdating { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -264,6 +264,9 @@ namespace Artemis.Storage.Migrations b.Property("InstalledAt") .HasColumnType("TEXT"); + b.Property("IsOfficial") + .HasColumnType("INTEGER"); + b.Property("LatestReleaseId") .HasColumnType("INTEGER"); diff --git a/src/Artemis.Storage/Migrations/20240706131336_ExpandInstalledEntry.cs b/src/Artemis.Storage/Migrations/20240722084220_AutoUpdating.cs similarity index 88% rename from src/Artemis.Storage/Migrations/20240706131336_ExpandInstalledEntry.cs rename to src/Artemis.Storage/Migrations/20240722084220_AutoUpdating.cs index 5e7831dbf..fe1aaa710 100644 --- a/src/Artemis.Storage/Migrations/20240706131336_ExpandInstalledEntry.cs +++ b/src/Artemis.Storage/Migrations/20240722084220_AutoUpdating.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace Artemis.Storage.Migrations { /// - public partial class ExpandInstalledEntry : Migration + public partial class AutoUpdating : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -38,6 +38,13 @@ namespace Artemis.Storage.Migrations nullable: false, defaultValue: 0L); + migrationBuilder.AddColumn( + name: "IsOfficial", + table: "Entries", + type: "INTEGER", + nullable: false, + defaultValue: false); + migrationBuilder.AddColumn( name: "LatestReleaseId", table: "Entries", @@ -50,7 +57,7 @@ namespace Artemis.Storage.Migrations type: "TEXT", nullable: false, defaultValue: ""); - + // Enable auto-update on all entries that are not profiles migrationBuilder.Sql("UPDATE Entries SET AutoUpdate = 1 WHERE EntryType != 2"); @@ -87,6 +94,10 @@ namespace Artemis.Storage.Migrations name: "Downloads", table: "Entries"); + migrationBuilder.DropColumn( + name: "IsOfficial", + table: "Entries"); + migrationBuilder.DropColumn( name: "LatestReleaseId", table: "Entries"); diff --git a/src/Artemis.Storage/Migrations/ArtemisDbContextModelSnapshot.cs b/src/Artemis.Storage/Migrations/ArtemisDbContextModelSnapshot.cs index 2be8631f6..04a34e87b 100644 --- a/src/Artemis.Storage/Migrations/ArtemisDbContextModelSnapshot.cs +++ b/src/Artemis.Storage/Migrations/ArtemisDbContextModelSnapshot.cs @@ -261,6 +261,9 @@ namespace Artemis.Storage.Migrations b.Property("InstalledAt") .HasColumnType("TEXT"); + b.Property("IsOfficial") + .HasColumnType("INTEGER"); + b.Property("LatestReleaseId") .HasColumnType("INTEGER"); diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabItemView.axaml b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabItemView.axaml index d9b7e978b..b45a8d3e8 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabItemView.axaml +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabItemView.axaml @@ -39,7 +39,7 @@ by you - + _updateNotificationProvider; private readonly PluginSetting _showNotifications; - public WorkshopUpdateService(ILogger logger, IWorkshopClient client, IWorkshopService workshopService, ISettingsService settingsService, - Lazy updateNotificationProvider) + public WorkshopUpdateService(ILogger logger, IWorkshopClient client, IWorkshopService workshopService, ISettingsService settingsService, Lazy updateNotificationProvider) { _logger = logger; _client = client; @@ -69,15 +66,27 @@ public class WorkshopUpdateService : IWorkshopUpdateService _logger.Information("Auto-updating entry {Entry} to version {Version}", entry, latestRelease.Version); - EntryInstallResult updateResult = await _workshopService.InstallEntry(entry, latestRelease, new Progress(), CancellationToken.None); + try + { + EntryInstallResult updateResult = await _workshopService.InstallEntry(entry, latestRelease, new Progress(), CancellationToken.None); - // This happens during installation too but not on our reference of the entry - if (updateResult.IsSuccess) - entry.ApplyRelease(latestRelease); + // This happens during installation too but not on our reference of the entry + if (updateResult.IsSuccess) + entry.ApplyRelease(latestRelease); - _logger.Information("Auto-update result: {Result}", updateResult); + if (updateResult.IsSuccess) + _logger.Information("Auto-update successful for entry {Entry}", entry); + else + _logger.Warning("Auto-update failed for entry {Entry}: {Message}", entry, updateResult.Message); - return updateResult.IsSuccess; + return updateResult.IsSuccess; + } + catch (Exception e) + { + _logger.Warning(e, "Auto-update failed for entry {Entry}", entry); + } + + return false; } /// diff --git a/src/Artemis.WebClient.Workshop/Models/InstalledEntry.cs b/src/Artemis.WebClient.Workshop/Models/InstalledEntry.cs index d9d872674..76f0487c1 100644 --- a/src/Artemis.WebClient.Workshop/Models/InstalledEntry.cs +++ b/src/Artemis.WebClient.Workshop/Models/InstalledEntry.cs @@ -65,6 +65,7 @@ public class InstalledEntry : CorePropertyChanged, IEntrySummary { Id = Entity.EntryId; Author = Entity.Author; + IsOfficial = Entity.IsOfficial; Name = Entity.Name; Summary = Entity.Summary; EntryType = (EntryType) Entity.EntryType; @@ -87,6 +88,7 @@ public class InstalledEntry : CorePropertyChanged, IEntrySummary Entity.EntryType = (int) EntryType; Entity.Author = Author; + Entity.IsOfficial = IsOfficial; Entity.Name = Name; Entity.Summary = Summary; Entity.Downloads = Downloads;