From 5476baa0c161b32faf5d33cba2963e46f4e861bc Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Wed, 20 Feb 2019 12:03:14 -0500 Subject: [PATCH 1/4] =?UTF-8?q?[bugfix]=20Store=20packages=E2=80=99=20eXis?= =?UTF-8?q?t=20version=20requirement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This info is needed when clients request packages that are compatible with specific versions of eXist. Otherwise, all packages will be presumed compatible with all versions of eXist (e.g., >2.2.0), and the app is unable to tell clients which version of a package is compatible with their actual version of eXist. --- modules/scan.xql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/scan.xql b/modules/scan.xql index c6812dc..1b5c5d4 100644 --- a/modules/scan.xql +++ b/modules/scan.xql @@ -47,7 +47,7 @@ declare function scanrepo:process($apps as element(app)*) { let $n := tokenize($older/version, "\.") ! xs:int(analyze-string(., "(\d+)")//fn:group[1]) order by $n[1], $n[2], $n[3] return - {$older/@path} + {$older/@path, $older/requires} ) } From 288acce69e3d61c4539f346fa061bfb2df195033 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Wed, 20 Feb 2019 12:10:23 -0500 Subject: [PATCH 2/4] [bugfix] Include old versions when searching pkgs Clients request the newest version of a package compatible with their processor. Before this PR, eXist ignored previous versions of a package, so the repo would only supply the current package. As a result, users of older versions of eXist could be told there is no version of the package compatible with their system, when in fact older versions of the package compatible with their system should be supplied. This fixes the problem. --- modules/app.xql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/app.xql b/modules/app.xql index a97d495..8b737ef 100644 --- a/modules/app.xql +++ b/modules/app.xql @@ -44,8 +44,9 @@ declare function app:view-package($node as node(), $model as map(*), $mode as xs response:redirect-to(xs:anyURI($info-url)) (: view current package info :) else - let $compatible-xar := app:find-version($app, $procVersion, (), (), (), ()) - let $package := $app[@path eq $compatible-xar] + let $app-versions := ($app, $app/other/version) + let $compatible-xar := app:find-version($app-versions, $procVersion, (), (), (), ()) + let $package := $app-versions[@path eq $compatible-xar] let $show-details := true() return app:package-to-list-item($package, $show-details) From ecf166a02c3e855156843c03a481eaba1a42ad70 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Wed, 20 Feb 2019 12:17:48 -0500 Subject: [PATCH 3/4] [ignore] cleanup - align code for looking up compatible packages with other modules - info view should show only info about the compatible version of the package, not info all about all app versions --- modules/find.xql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/find.xql b/modules/find.xql index 55e5667..74a751b 100644 --- a/modules/find.xql +++ b/modules/find.xql @@ -21,7 +21,8 @@ let $app := collection($config:app-root || "/public")//app[name eq $name] else collection($config:app-root || "/public")//app[abbrev eq $abbrev] -let $compatible-xar := app:find-version($app | $app/other/version, $procVersion, $version, $semVer, $minVersion, $maxVersion) +let $app-versions := ($app, $app/other/version) +let $compatible-xar := app:find-version($app-versions, $procVersion, $version, $semVer, $minVersion, $maxVersion) return if ($compatible-xar) then let $rel-public := @@ -31,7 +32,7 @@ return "public/" return if ($info) then - {$app} + {$compatible-xar} else if ($zip) then response:redirect-to(xs:anyURI($rel-public || $compatible-xar || ".zip")) else From 762a35f4d61ba42b29a4f176ec2db20b6a2f6260 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Wed, 20 Feb 2019 12:44:03 -0500 Subject: [PATCH 4/4] [bugfix] Avoid 400 error when pkg not found Previously, a request for a package like packages/foo.html or packages/monex.html?eXist-db-min-version=1.0.0 would return XQuery errors. This provides a proper 404 error and a human-readable error message for each condition. --- modules/app.xql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/app.xql b/modules/app.xql index 8b737ef..b9af900 100644 --- a/modules/app.xql +++ b/modules/app.xql @@ -49,7 +49,16 @@ declare function app:view-package($node as node(), $model as map(*), $mode as xs let $package := $app-versions[@path eq $compatible-xar] let $show-details := true() return - app:package-to-list-item($package, $show-details) + if (exists($package)) then + app:package-to-list-item($package, $show-details) + else + ( + response:set-status-code(404), + if (exists($app)) then +
  • Package {$abbrev} requires a newer version of eXist.
  • + else +
  • No package {$abbrev} is available.
  • + ) }; declare function app:package-to-list-item($app as element(app), $show-details as xs:boolean) {