@@ -212,7 +212,9 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
212
212
213
213
SET tSC =tDocument .EvaluateExpression (" /Export/Document/Module/Name" , " text()" , .tRes )
214
214
IF $$$ISERR(tSC ) Return tSC
215
-
215
+ If '$IsObject (tRes .GetAt (1 )) {
216
+ Return $$$ERROR($$$GeneralError, " Name required" )
217
+ }
216
218
SET name = tRes .GetAt (1 ).Value
217
219
SET name = $$$lcase(name )
218
220
If ('silent ) {
@@ -221,15 +223,19 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
221
223
222
224
SET tSC =tDocument .EvaluateExpression (" /Export/Document/Module/Version" , " text()" , .tRes )
223
225
IF $$$ISERR(tSC ) Return tSC
224
-
226
+ If '$IsObject (tRes .GetAt (1 )) {
227
+ Return $$$ERROR($$$GeneralError, " Version required" )
228
+ }
225
229
SET version = tRes .GetAt (1 ).Value
226
230
If ('silent ) {
227
231
WRITE !," Version: " , version
228
232
}
229
233
230
- SET tSC =tDocument .EvaluateExpression (" /Export/Document/Module/Description" , " text()" , .tRes )
234
+ Set tSC =tDocument .EvaluateExpression (" /Export/Document/Module/Description" , " text()" , .tRes )
231
235
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
+ }
233
239
234
240
SET archive = ##class (%Stream.FileBinary ).%New ()
235
241
SET archiveFileName = ##class (%File ).TempFilename (" tgz" )
@@ -343,15 +349,17 @@ ClassMethod UpdatePackage(jo As %DynamicObject) As %Status
343
349
Set outputFolder = " "
344
350
Try {
345
351
Set url = jo .repository
346
- #; set url = $ZCONVERT(url, "L")
347
352
If $Extract (url , *)'=" /" {
348
353
Set url = url _ " /"
349
354
}
350
355
Set name = ..GetPackageNameFromRepositoryURL (url )
351
356
Set meta = ..GetModuleMeta (url )
352
357
If (meta .version = " " ) { $$$ThrowStatus($$$ERROR(5001 , " Invalid package version" )) }
353
358
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 '=" " ) {
355
363
If (..repositoryGetStored (id )'=url ) {
356
364
$$$ThrowStatus($$$ERROR(5001 , " Invalid repository for this Package" ))
357
365
} Else {
@@ -363,17 +371,17 @@ ClassMethod UpdatePackage(jo As %DynamicObject) As %Status
363
371
} Else {
364
372
If (..RepositoryExists (url , .id )) {
365
373
$$$ThrowStatus($$$ERROR(5001 , " This repository was published under a different name" ))
366
- } else {
374
+ } Else {
367
375
Set sc = ..Publish (url , name )
368
376
}
369
377
}
370
378
} Catch ex {
371
379
Set sc = ex .AsStatus ()
372
380
}
373
- if (outputFolder '=" " ) {
374
- do ##class (%File ).RemoveDirectoryTree (outputFolder )
381
+ If (outputFolder '=" " ) {
382
+ Do ##class (%File ).RemoveDirectoryTree (outputFolder )
375
383
}
376
- return sc
384
+ Return sc
377
385
}
378
386
379
387
ClassMethod Publish (url As %String , name As %String ) As %Status
0 commit comments