Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeekman committed Mar 14, 2024
2 parents 8c1fef2 + fa8b031 commit e588a06
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Artemis.Core/Services/PluginManagementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,18 @@ public void UnloadPlugins()
);
}

bool addedNewFeature = false;
foreach (Type featureType in featureTypes)
{
// Load the enabled state and if not found, default to true
PluginFeatureEntity featureEntity = plugin.Entity.Features.FirstOrDefault(i => i.Type == featureType.FullName) ?? new PluginFeatureEntity {Type = featureType.FullName!};
PluginFeatureEntity? featureEntity = plugin.Entity.Features.FirstOrDefault(i => i.Type == featureType.FullName);
if (featureEntity == null)
{
featureEntity = new PluginFeatureEntity {Type = featureType.FullName!};
entity.Features.Add(featureEntity);
addedNewFeature = true;
}

PluginFeatureInfo feature = new(plugin, featureType, featureEntity, (PluginFeatureAttribute?) Attribute.GetCustomAttribute(featureType, typeof(PluginFeatureAttribute)));

// If the plugin only has a single feature, it should always be enabled
Expand All @@ -443,7 +451,8 @@ public void UnloadPlugins()

// It is appropriate to call this now that we have the features of this plugin
bool autoEnabled = plugin.AutoEnableIfNew();
if (autoEnabled)

if (autoEnabled || addedNewFeature)
_pluginRepository.SavePlugin(entity);

List<Type> bootstrappers = plugin.Assembly.GetTypes().Where(t => typeof(PluginBootstrapper).IsAssignableFrom(t)).ToList();
Expand Down

0 comments on commit e588a06

Please sign in to comment.