diff --git a/CHANGELOG.md b/CHANGELOG.md index bca97a20..15400e51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - #451: Avoid compliation errors due to storage location conflict on IRIS for Health prior to 2024.1 - #455: Upgrade from %ZPM classes updates language extensions correctly to use %IPM - #373: Cleaner cross-version approach used in language extension routine generation +- #459: zpm "version" behaves better without internet access ### Security - diff --git a/src/cls/IPM/Main.cls b/src/cls/IPM/Main.cls index cbc2d876..3e8403bc 100644 --- a/src/cls/IPM/Main.cls +++ b/src/cls/IPM/Main.cls @@ -1145,7 +1145,7 @@ ClassMethod Version(ByRef pCommandInfo) [ Internal ] $$$ThrowOnError(tSC) Set tService = tRepository.GetPackageService() Set tInfo = tService.GetInfo() - Write !,$$$FormattedLine($$$Blue,tRepository.URL)," - ",tInfo.version + Write !,$$$FormattedLine($$$Blue,tRepository.URL)," - ",tInfo.ToString() } Quit $$$OK } diff --git a/src/cls/IPM/Repo/Remote/Info.cls b/src/cls/IPM/Repo/Remote/Info.cls new file mode 100644 index 00000000..0d85c8da --- /dev/null +++ b/src/cls/IPM/Repo/Remote/Info.cls @@ -0,0 +1,15 @@ +Class %IPM.Repo.Remote.Info Extends (%RegisteredObject, %JSON.Adaptor) +{ + +Parameter %JSONIGNOREINVALIDFIELD As BOOLEAN = 1; + +Property version As %String; + +Property available As %Boolean [ InitialExpression = 1 ]; + +Method ToString() As %String +{ + Quit $Select(..available:..version,1:"currently unavailable") +} + +} diff --git a/src/cls/IPM/Repo/Remote/PackageService.cls b/src/cls/IPM/Repo/Remote/PackageService.cls index 22ea1e32..b952a9de 100644 --- a/src/cls/IPM/Repo/Remote/PackageService.cls +++ b/src/cls/IPM/Repo/Remote/PackageService.cls @@ -11,17 +11,20 @@ Property Password As %String; Property Token As %String; -Method GetInfo(url As %String) As %DynamicObject +Method GetInfo() As %IPM.Repo.Remote.Info { Set tRequest = ..GetHttpRequest() + Set tRequest.Timeout = 2 // Short timeout in case it's unavailable Set tSC = tRequest.Get() + Set info = ##class(%IPM.Repo.Remote.Info).%New() If $$$ISOK(tSC), tRequest.HttpResponse.StatusCode=200 { - Set tRes = {}.%FromJSON(tRequest.HttpResponse.Data) - Return tRes + $$$ThrowOnError(info.%JSONImport(tRequest.HttpResponse.Data)) + } Else { + Set info.available = 0 } - - $$$ThrowStatus($$$ERROR($$$GeneralError,"Registry server not available.")) + + Return info } Method GetLatestModuleVersion(pModuleName As %String) As %String diff --git a/src/cls/IPM/ResourceProcessor/FileCopy.cls b/src/cls/IPM/ResourceProcessor/FileCopy.cls index de6b2402..7be88a24 100644 --- a/src/cls/IPM/ResourceProcessor/FileCopy.cls +++ b/src/cls/IPM/ResourceProcessor/FileCopy.cls @@ -39,7 +39,7 @@ Method OnBeforePhase(pPhase As %String, ByRef pParams) As %Status } If (pPhase = "Activate") && (..InstallDirectory '= "") && ('..Defer) { - Set tSource = $Case(..SourceDirectory, "": ..ResourceReference.Module.Root _ ..ResourceReference.Name,: ..SourceDirectory) + Set tSource = ..ResourceReference.Module.Root _ $Case(..SourceDirectory, "": ..ResourceReference.Name,: ..SourceDirectory) Set tTarget = ..InstallDirectory Set tSC = ..DoCopy(tSource, tTarget, .pParams) If $$$ISERR(tSC) { @@ -65,7 +65,7 @@ Method OnAfterPhase(pPhase As %String, ByRef pParams) As %Status } If (pPhase = "Activate") && (..InstallDirectory '= "") && (..Defer) { - Set tSource = $Case(..SourceDirectory, "": ..ResourceReference.Module.Root _..ResourceReference.Name,: ..SourceDirectory) + Set tSource = ..ResourceReference.Module.Root _ $Case(..SourceDirectory, "": ..ResourceReference.Name,: ..SourceDirectory) Set tTarget = ..InstallDirectory Set tSC = ..DoCopy(tSource, tTarget, .pParams) If $$$ISERR(tSC) { @@ -138,7 +138,7 @@ Method DoCopy(tSource, tTarget, pParams) Write:tVerbose !,"Copying ",tSource," to ",tTarget If (copyAsFile) { If '##class(%File).Exists(tSource) { - Set tSC = $$$ERROR($$$GeneralError, "Source file does not exists: "_tSource) + Set tSC = $$$ERROR($$$GeneralError, "Source file does not exist: "_tSource) Quit } If '##class(%File).CopyFile(tSource, tTarget, 1, .return) {