Skip to content

Commit ab59abc

Browse files
committed
fix xpath working with stream
1 parent 95b2849 commit ab59abc

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/cls/ZPM/Package.cls

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,30 @@ ClassMethod GetModuleMeta(url As %String) As %DynamicObject
286286
Set ht.Port = port
287287
}
288288
Set ht.Location = tComponents("path")_"master/module.xml"
289-
290289
$$$ThrowOnError(ht.Get())
291290
If (ht.HttpResponse.StatusCode'=200) {
292291
$$$ThrowStatus($$$ERROR(5001,"Unable to download XML "_ht.Location))
293292
}
294-
$$$ThrowOnError(##class(%XML.XPATH.Document).CreateFromStream(ht.HttpResponse.Data, .xpathdoc))
293+
Set tmpFolder = $$$FileTempDir
294+
Do ##class(%File).CreateDirectory(tmpFolder)
295+
296+
Set stream=##class(%Stream.FileCharacter).%New()
297+
Do stream.LinkToFile(tmpFolder_"/module.xml")
298+
Set stream.TranslateTable = "UTF8"
299+
Do stream.CopyFrom(ht.HttpResponse.Data)
300+
Do stream.%Save()
301+
302+
set binaryStream=##class(%Stream.FileBinary).%New()
303+
do binaryStream.LinkToFile(tmpFolder_"/module.xml")
304+
305+
$$$ThrowOnError(##class(%XML.XPATH.Document).CreateFromStream(binaryStream, .xpathdoc))
295306
$$$ThrowOnError(xpathdoc.EvaluateExpression("/","Export/Document/Module/Version/text()", .tResults))
296307
set jo.version = tResults.GetAt(1).ValueGet()
297308
$$$ThrowOnError(xpathdoc.EvaluateExpression("/","Export/Document/Module/Name/text()", .tResults))
298309
set jo.name = tResults.GetAt(1).ValueGet()
310+
311+
Do ##class(%File).RemoveDirectoryTree(tmpFolder)
312+
299313
return jo
300314
}
301315

@@ -339,7 +353,6 @@ ClassMethod UpdatePackage(jo As %DynamicObject) As %Status
339353

340354
ClassMethod Publish(url As %String, name As %String) As %Status
341355
{
342-
343356
Set outputFolder = ..DownloadPackageFromGitHub(url)
344357
Set packageFolder = ##class(%File).NormalizeDirectory(name _ "-master", outputFolder)
345358
Return ..LoadPackage(packageFolder, url, 1)

0 commit comments

Comments
 (0)