Skip to content

Commit eb93e62

Browse files
authored
Merge pull request #33 from intersystems-community/fix-publish
Fix publish
2 parents a0e1ed1 + e1615bb commit eb93e62

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Module>
55
<Name>zpm-registry</Name>
66
<Description>Registry server for ZPM</Description>
7-
<Version>1.0.8</Version>
7+
<Version>1.0.9</Version>
88
<Packaging>module</Packaging>
99
<SourcesRoot>src</SourcesRoot>
1010
<Resource Name="ZPM.PKG"/>

src/cls/ZPM/Package.cls

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
212212

213213
SET tSC=tDocument.EvaluateExpression("/Export/Document/Module/Name", "text()", .tRes)
214214
IF $$$ISERR(tSC) Return tSC
215-
215+
If '$IsObject(tRes.GetAt(1)) {
216+
Return $$$ERROR($$$GeneralError, "Name required")
217+
}
216218
SET name = tRes.GetAt(1).Value
217219
SET name = $$$lcase(name)
218220
If ('silent) {
@@ -221,15 +223,19 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
221223

222224
SET tSC=tDocument.EvaluateExpression("/Export/Document/Module/Version", "text()", .tRes)
223225
IF $$$ISERR(tSC) Return tSC
224-
226+
If '$IsObject(tRes.GetAt(1)) {
227+
Return $$$ERROR($$$GeneralError, "Version required")
228+
}
225229
SET version = tRes.GetAt(1).Value
226230
If ('silent) {
227231
WRITE !,"Version: ", version
228232
}
229233

230-
SET tSC=tDocument.EvaluateExpression("/Export/Document/Module/Description", "text()", .tRes)
234+
Set tSC=tDocument.EvaluateExpression("/Export/Document/Module/Description", "text()", .tRes)
231235
IF $$$ISERR(tSC) Return tSC
232-
SET description = tRes.GetAt(1).Value
236+
If $IsObject(tRes.GetAt(1)) {
237+
Set description = tRes.GetAt(1).Value
238+
}
233239

234240
SET archive = ##class(%Stream.FileBinary).%New()
235241
SET archiveFileName = ##class(%File).TempFilename("tgz")
@@ -343,15 +349,17 @@ ClassMethod UpdatePackage(jo As %DynamicObject) As %Status
343349
Set outputFolder = ""
344350
Try {
345351
Set url = jo.repository
346-
#; set url = $ZCONVERT(url, "L")
347352
If $Extract(url, *)'="/" {
348353
Set url = url _ "/"
349354
}
350355
Set name = ..GetPackageNameFromRepositoryURL(url)
351356
Set meta = ..GetModuleMeta(url)
352357
If (meta.version = "") { $$$ThrowStatus($$$ERROR(5001, "Invalid package version")) }
353358
If (meta.name = "") { $$$ThrowStatus($$$ERROR(5001, "Package name is empty")) }
354-
If (..NameExists(meta.name, .id)) {
359+
Set tName = meta.name
360+
Set id = ""
361+
&sql(SELECT ID into :id FROM ZPM.Package WHERE name=:tName ORDER BY versionMajor DESC, versionMinor DESC, versionPatch DESC, versionPrerelease DESC)
362+
If (id'="") {
355363
If (..repositoryGetStored(id)'=url) {
356364
$$$ThrowStatus($$$ERROR(5001, "Invalid repository for this Package"))
357365
} Else {
@@ -363,17 +371,17 @@ ClassMethod UpdatePackage(jo As %DynamicObject) As %Status
363371
} Else {
364372
If (..RepositoryExists(url, .id)) {
365373
$$$ThrowStatus($$$ERROR(5001, "This repository was published under a different name"))
366-
} else {
374+
} Else {
367375
Set sc = ..Publish(url, name)
368376
}
369377
}
370378
} Catch ex {
371379
Set sc = ex.AsStatus()
372380
}
373-
if (outputFolder'="") {
374-
do ##class(%File).RemoveDirectoryTree(outputFolder)
381+
If (outputFolder'="") {
382+
Do ##class(%File).RemoveDirectoryTree(outputFolder)
375383
}
376-
return sc
384+
Return sc
377385
}
378386

379387
ClassMethod Publish(url As %String, name As %String) As %Status

0 commit comments

Comments
 (0)