Path fix for Windows

This commit is contained in:
dotasek 2023-09-09 07:57:09 -07:00
parent e9b1e63e04
commit eb81b0abb4
2 changed files with 16 additions and 1 deletions

View File

@ -146,7 +146,11 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
switch (mode) {
case SYSTEM:
cacheFolder = new File(Utilities.path("/var", "lib", ".fhir", "packages"));
if (Utilities.isWindows()) {
cacheFolder = new File(Utilities.path("C:","ProgramData", ".fhir", "packages"));
} else {
cacheFolder = new File(Utilities.path("/var", "lib", ".fhir", "packages"));
}
break;
case USER:
cacheFolder = new File(Utilities.path(System.getProperty("user.home"), ".fhir", "packages"));

View File

@ -10,6 +10,7 @@ import javax.annotation.Nonnull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
public class FilesystemPackageManagerTests {
@ -89,4 +90,14 @@ public class FilesystemPackageManagerTests {
};
assertEquals( "/var/lib/.fhir/packages", filesystemPackageCacheManager.getFolder());
}
@Test
@EnabledOnOs(OS.WINDOWS)
public void testSystemCacheDirectoryWin() throws IOException {
FilesystemPackageCacheManager filesystemPackageCacheManager = new FilesystemPackageCacheManager(false) {
protected void initCacheFolder() throws IOException {
}
};
assertEquals( "C:\\ProgramData\\.fhir\\packages", filesystemPackageCacheManager.getFolder());
}
}