mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 08:15:37 +00:00
[untested] Set db and cache path from first library root
This commit is contained in:
+8
-1
@@ -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) {
|
||||
Reference in New Issue
Block a user