check for latest version of package
This commit is contained in:
parent
f8268442d1
commit
4a8d626ab9
|
@ -228,11 +228,14 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
|
||||
public String getLatestVersion(String id) throws IOException {
|
||||
for (String nextPackageServer : getPackageServers()) {
|
||||
CachingPackageClient pc = new CachingPackageClient(nextPackageServer);
|
||||
try {
|
||||
return pc.getLatestVersion(id);
|
||||
} catch (IOException e) {
|
||||
ourLog.info("Failed to determine latest version of package {} from server: {}", id, nextPackageServer);
|
||||
// special case:
|
||||
if (!("hl7.fhir.pubpack".equals(id) && PRIMARY_SERVER.equals(nextPackageServer))) {
|
||||
CachingPackageClient pc = new CachingPackageClient(nextPackageServer);
|
||||
try {
|
||||
return pc.getLatestVersion(id);
|
||||
} catch (IOException e) {
|
||||
ourLog.info("Failed to determine latest version of package {} from server: {}", id, nextPackageServer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,6 +477,13 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
id = id.substring(0, id.indexOf("#"));
|
||||
}
|
||||
|
||||
if (version == null) {
|
||||
try {
|
||||
version = getLatestVersion(id);
|
||||
} catch (Exception e) {
|
||||
version = null;
|
||||
}
|
||||
}
|
||||
NpmPackage p = loadPackageFromCacheOnly(id, version);
|
||||
if (p != null) {
|
||||
if ("current".equals(version)) {
|
||||
|
|
|
@ -53,7 +53,14 @@ public class PackageCacheTests {
|
|||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
cache.clear();
|
||||
Assertions.assertEquals(cache.loadPackage("KBV.Basis", "1.1.3").version(), "1.1.3");
|
||||
Assertions.assertEquals(cache.loadPackage("kbv.basis", "1.1.3").version(), "1.1.3");
|
||||
|
||||
Assertions.assertEquals(cache.loadPackage("kbv.basis", "1.1.3").version(), "1.1.3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLastReleasedVersion() throws IOException {
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
cache.clear();
|
||||
Assertions.assertEquals("0.0.8", cache.loadPackage("hl7.fhir.pubpack", "0.0.8").version());
|
||||
Assertions.assertEquals("0.0.9", cache.loadPackage("hl7.fhir.pubpack").version());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue