mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-17 08:15:44 +00:00
Fix "gameyfin.cache" and "gameyfin.db" properties are ignored
This commit is contained in:
@@ -9,6 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.core.env.*;
|
import org.springframework.core.env.*;
|
||||||
import org.springframework.util.PropertyPlaceholderHelper;
|
import org.springframework.util.PropertyPlaceholderHelper;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -21,14 +22,27 @@ public class FilesystemConfig {
|
|||||||
@Value("#{'${gameyfin.sources}'.split(',')[0]}")
|
@Value("#{'${gameyfin.sources}'.split(',')[0]}")
|
||||||
private String firstLibraryPath;
|
private String firstLibraryPath;
|
||||||
|
|
||||||
|
@Value("${gameyfin.db}")
|
||||||
|
private String dbPath;
|
||||||
|
|
||||||
|
@Value("${gameyfin.cache}")
|
||||||
|
private String cachePath;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
Environment env;
|
Environment env;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setConfigurableEnvironment(ConfigurableEnvironment env) {
|
public void setConfigurableEnvironment(ConfigurableEnvironment env) {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|
||||||
|
if(!StringUtils.hasText(dbPath)) {
|
||||||
props.setProperty("gameyfin.db", "%s/.gameyfin/db".formatted(firstLibraryPath));
|
props.setProperty("gameyfin.db", "%s/.gameyfin/db".formatted(firstLibraryPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.hasText(cachePath)) {
|
||||||
props.setProperty("gameyfin.cache", "%s/.gameyfin/cache".formatted(firstLibraryPath));
|
props.setProperty("gameyfin.cache", "%s/.gameyfin/cache".formatted(firstLibraryPath));
|
||||||
|
}
|
||||||
|
|
||||||
env.getPropertySources().addFirst(new PropertiesPropertySource("gameyfinFilesystemProperties", props));
|
env.getPropertySources().addFirst(new PropertiesPropertySource("gameyfinFilesystemProperties", props));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user