[untested] Set db and cache path from first library root

This commit is contained in:
Simon Grimme
2022-08-13 11:19:36 +02:00
parent da8e075cfc
commit 7a3a323212
@@ -9,13 +9,20 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import java.util.Objects;
import java.util.Properties;
@Configuration
public class SecureProperties {
public class CustomConfiguratioLoader {
@Autowired
public void setConfigurableEnvironment(ConfigurableEnvironment env) {
try {
String firstLibraryPath = env.resolvePlaceholders("gameyfin.root").split(",")[0];
Properties props = new Properties();
props.setProperty("gameyfin.db", "%s/.gameyfin/db".formatted(firstLibraryPath));
props.setProperty("gameyfin.cache", "%s/.gameyfin/cache".formatted(firstLibraryPath));
env.getPropertySources().addFirst(new PropertiesPropertySource("dynamicallyLoadedGameyfinProperties", props));
Resource resource = new ClassPathResource("/config/secure.yml");
env.getPropertySources().addFirst(new PropertiesPropertySource(Objects.requireNonNull(resource.getFilename()), PropertiesLoaderUtils.loadProperties(resource)));
} catch (Exception ex) {