From c99f884fc18457a80bb6daff94c886662adbd593 Mon Sep 17 00:00:00 2001 From: Skovlund Date: Fri, 16 Aug 2024 13:05:04 +0200 Subject: [PATCH] Changed plugin registration to create a new assembly, if major/minor version number was bumped. --- src/Delegate.Daxif/Modules/Plugins/Compare.fs | 31 ++++++++++--------- .../Modules/Plugins/MainHelper.fs | 7 +++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Delegate.Daxif/Modules/Plugins/Compare.fs b/src/Delegate.Daxif/Modules/Plugins/Compare.fs index 34b9c04..0dd55b6 100644 --- a/src/Delegate.Daxif/Modules/Plugins/Compare.fs +++ b/src/Delegate.Daxif/Modules/Plugins/Compare.fs @@ -138,20 +138,21 @@ let image (img: Image) (x: Entity) = /// Compares an assembly from CRM with the one containing the source code /// Returns true if the assembly in CRM is newer and the hash matches the one in the source code -let registeredIsSameAsLocal (local: AssemlyLocal) (registered: AssemblyRegistration option) = - registered - ?|> fun y -> - let log = ConsoleLogger.Global - - let environmentIsNewer = y.version .>= local.version - log.Verbose "Registered version %s is %s than local version %s" - (y.version |> versionToString) (if environmentIsNewer then "newer" else "older") (local.version |> versionToString) - - let hashMatch = y.hash = local.hash - log.Verbose "Registered assembly hash %s local assembly hash" (if hashMatch then "matches" else "does not match") +let registeredIsSameAsLocal (local: AssemlyLocal) (registered: AssemblyRegistration) = + let log = ConsoleLogger.Global - let isSameAssembly = environmentIsNewer && hashMatch - log.Verbose "Assembly will%s be updated" (if isSameAssembly then " not" else "") + let environmentIsNewer = registered.version .>= local.version + log.Verbose "Registered version %s is %s than local version %s" + (registered.version |> versionToString) (if environmentIsNewer then "newer" else "older") (local.version |> versionToString) - isSameAssembly - ?| false \ No newline at end of file + let hashMatch = registered.hash = local.hash + log.Verbose "Registered assembly hash %s local assembly hash" (if hashMatch then "matches" else "does not match") + + let isSameAssembly = environmentIsNewer && hashMatch + log.Verbose "Assembly will%s be updated" (if isSameAssembly then " not" else "") + + let majorMinorUpdate = + (local.version, registered.version) + |> fun ((a1, b1, _, _), (a2, b2, _, _)) -> a1 > a2 || (a1 = a2 && b1 > b2) + + isSameAssembly, majorMinorUpdate \ No newline at end of file diff --git a/src/Delegate.Daxif/Modules/Plugins/MainHelper.fs b/src/Delegate.Daxif/Modules/Plugins/MainHelper.fs index 151c256..97ce459 100644 --- a/src/Delegate.Daxif/Modules/Plugins/MainHelper.fs +++ b/src/Delegate.Daxif/Modules/Plugins/MainHelper.fs @@ -65,8 +65,11 @@ let localToMaps (plugins: Plugin seq) (customAPIs: CustomAPI seq) = /// Determine which operation we want to perform on the assembly let determineOperation (asmReg: AssemblyRegistration option) (asmLocal) : AssemblyOperation * Guid = match asmReg with - | Some asm when Compare.registeredIsSameAsLocal asmLocal (Some asm) -> Unchanged, asm.id - | Some asm -> Update, asm.id + | Some asm -> + match Compare.registeredIsSameAsLocal asmLocal asm with + | true, _ -> Unchanged, asm.id + | false, false -> Update, asm.id + | false, true -> Create, Guid.Empty | None -> Create, Guid.Empty /// Update or create assembly