Skip to content

Commit

Permalink
Merge pull request #3175 from sbwalker/dev
Browse files Browse the repository at this point in the history
resolve module installation issue where ModuleDefinition Version property was not being populated correctly
  • Loading branch information
sbwalker authored Aug 23, 2023
2 parents 3729b8e + d9948e8 commit f269a07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 10 additions & 8 deletions Oqtane.Server/Repository/ModuleDefinitionRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,29 @@ private List<ModuleDefinition> ProcessModuleDefinitions(int siteId)
if (moduledefinition == null)
{
// new module definition
moduledefinition = new ModuleDefinition { ModuleDefinitionName = ModuleDefinition.ModuleDefinitionName };
moduledefinition = new ModuleDefinition { ModuleDefinitionName = ModuleDefinition.ModuleDefinitionName, Version = ModuleDefinition.Version };
_db.ModuleDefinition.Add(moduledefinition);
_db.SaveChanges();
ModuleDefinition.Version = "";
ModuleDefinition.Version = ""; // ensure migrations are executed during startup
}
else
{
// override user customizable property values
ModuleDefinition.Name = (!string.IsNullOrEmpty(moduledefinition.Name)) ? moduledefinition.Name : ModuleDefinition.Name;
ModuleDefinition.Description = (!string.IsNullOrEmpty(moduledefinition.Description)) ? moduledefinition.Description : ModuleDefinition.Description;
ModuleDefinition.Categories = (!string.IsNullOrEmpty(moduledefinition.Categories)) ? moduledefinition.Categories : ModuleDefinition.Categories;
// manage releaseversions in cases where it was not provided or is lower than the module version
if (string.IsNullOrEmpty(ModuleDefinition.ReleaseVersions) || Version.Parse(ModuleDefinition.Version).CompareTo(Version.Parse(ModuleDefinition.ReleaseVersions.Split(',').Last())) > 0)
{
ModuleDefinition.ReleaseVersions = ModuleDefinition.Version;
}
ModuleDefinition.Version = moduledefinition.Version;

// remove module definition from list as it is already synced
moduledefinitions.Remove(moduledefinition);
}

// manage releaseversions in cases where it was not provided or is lower than the module version
if (string.IsNullOrEmpty(ModuleDefinition.ReleaseVersions) || Version.Parse(ModuleDefinition.Version).CompareTo(Version.Parse(ModuleDefinition.ReleaseVersions.Split(',').Last())) > 0)
{
ModuleDefinition.ReleaseVersions = ModuleDefinition.Version;
}

// load db properties
ModuleDefinition.ModuleDefinitionId = moduledefinition.ModuleDefinitionId;
ModuleDefinition.CreatedBy = moduledefinition.CreatedBy;
ModuleDefinition.CreatedOn = moduledefinition.CreatedOn;
Expand Down
4 changes: 3 additions & 1 deletion Oqtane.Server/Repository/ThemeRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ private List<Theme> ProcessThemes(int siteId)
if (theme == null)
{
// new theme
theme = new Theme { ThemeName = Theme.ThemeName };
theme = new Theme { ThemeName = Theme.ThemeName, Version = Theme.Version };
_db.Theme.Add(theme);
_db.SaveChanges();
}
else
{
// override user customizable property values
Theme.Name = (!string.IsNullOrEmpty(theme.Name)) ? theme.Name : Theme.Name;

// remove theme from list as it is already synced
themes.Remove(theme);
}
Expand All @@ -141,6 +142,7 @@ private List<Theme> ProcessThemes(int siteId)
themecontrol.Name = Theme.Name + " - " + themecontrol.Name;
}

// load db properties
Theme.ThemeId = theme.ThemeId;
Theme.CreatedBy = theme.CreatedBy;
Theme.CreatedOn = theme.CreatedOn;
Expand Down

0 comments on commit f269a07

Please sign in to comment.