From 763bd6305608f8c1e432c2da887c28b5b9bd63fe Mon Sep 17 00:00:00 2001 From: Simon Grimme <9295182+grimsi@users.noreply.github.com> Date: Fri, 12 Aug 2022 22:08:19 +0200 Subject: [PATCH 1/6] Added support for multiple library folders --- .../gameyfin/service/LibraryService.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java index 3531176..49876e7 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java +++ b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java @@ -10,14 +10,17 @@ import de.grimsi.gameyfin.repositories.DetectedGameRepository; import de.grimsi.gameyfin.repositories.UnmappableFileRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StopWatch; import java.io.IOException; -import java.nio.file.*; -import java.util.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; @@ -30,24 +33,28 @@ import static de.grimsi.gameyfin.util.FilenameUtil.hasGameArchiveExtension; public class LibraryService { @Value("${gameyfin.root}") - private String rootFolderPath; + private List libraryFolders; private final IgdbWrapper igdbWrapper; private final DetectedGameRepository detectedGameRepository; private final UnmappableFileRepository unmappableFileRepository; public List getGameFiles() { + List gamefiles = new ArrayList<>(); - Path rootFolder = Path.of(rootFolderPath); + libraryFolders.parallelStream().map(Path::of).forEach(folder -> { + try (Stream stream = Files.list(folder)) { + // return all sub-folders (non-recursive) and files that have an extension that indicates that they are a downloadable file + List gameFilesFromThisFolder = stream.filter(p -> Files.isDirectory(p) || hasGameArchiveExtension(p)).toList(); + gamefiles.addAll(gameFilesFromThisFolder); - try (Stream stream = Files.list(rootFolder)) { - // return all sub-folders (non-recursive) and files that have an extension that indicates that they are a downloadable file - return stream - .filter(p -> Files.isDirectory(p) || hasGameArchiveExtension(p)) - .toList(); - } catch (IOException e) { - throw new RuntimeException("Error while opening root folder", e); - } + } catch (IOException e) { + throw new RuntimeException("Error while opening library folder '%s'".formatted(folder), e); + } + } + ); + + return gamefiles; } public void scanGameLibrary() { From 63d585b5d6191e32e9ed903a6a32137e155daafc Mon Sep 17 00:00:00 2001 From: grimsi <9295182+grimsi@users.noreply.github.com> Date: Fri, 12 Aug 2022 23:36:47 +0200 Subject: [PATCH 2/6] Fixed some bugs related to the property files --- .gitignore | 3 +- backend/pom.xml | 6 ++++ .../grimsi/gameyfin/GameyfinApplication.java | 2 +- .../gameyfin/config/SecureProperties.java | 2 +- .../gameyfin/service/LibraryService.java | 8 ++---- ...itional-spring-configuration-metadata.json | 9 ++++++ .../src/main/resources/application-dev.yml | 2 -- .../main/resources/config/database.properties | 13 --------- .../src/main/resources/config/database.yml | 18 ++++++++++++ .../main/resources/config/gameyfin.properties | 28 ------------------- .../src/main/resources/config/gameyfin.yml | 19 +++++++++++++ .../main/resources/config/secure.properties | 19 ------------- backend/src/main/resources/config/secure.yml | 27 ++++++++++++++++++ docker/docker-compose.example.yml | 4 +++ 14 files changed, 90 insertions(+), 70 deletions(-) create mode 100644 backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json delete mode 100644 backend/src/main/resources/config/database.properties create mode 100644 backend/src/main/resources/config/database.yml delete mode 100644 backend/src/main/resources/config/gameyfin.properties create mode 100644 backend/src/main/resources/config/gameyfin.yml delete mode 100644 backend/src/main/resources/config/secure.properties create mode 100644 backend/src/main/resources/config/secure.yml diff --git a/.gitignore b/.gitignore index 5d839f3..bbaa093 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,5 @@ build/ ### Custom ### /data/ /backend/src/main/resources/static/ -/docker/docker-compose.yml \ No newline at end of file +/docker/docker-compose.yml +/.gameyfin/ diff --git a/backend/pom.xml b/backend/pom.xml index 9734656..6906b6d 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -16,12 +16,16 @@ 18 + 1.6.9 1.7.1 2.11.0 1.21 3.11.4 3.21.3 + + + 3.1.0 @@ -140,6 +144,7 @@ **/*.properties **/*.yml **/*.yaml + **/*.json **/*.txt **/*.js **/*.css @@ -166,6 +171,7 @@ maven-resources-plugin + ${maven-resources-plugin.version} copy-resources diff --git a/backend/src/main/java/de/grimsi/gameyfin/GameyfinApplication.java b/backend/src/main/java/de/grimsi/gameyfin/GameyfinApplication.java index 4c79e1b..f17d349 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/GameyfinApplication.java +++ b/backend/src/main/java/de/grimsi/gameyfin/GameyfinApplication.java @@ -8,7 +8,7 @@ public class GameyfinApplication { public static void main(String[] args) { new SpringApplicationBuilder(GameyfinApplication.class) - .properties("spring.config.name=application,gameyfin,database,secure") + .properties( "file.encoding=UTF-8", "spring.config.name=application,gameyfin,database,secure") .build() .run(args); } diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java b/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java index 6d66527..3140b37 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java +++ b/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java @@ -16,7 +16,7 @@ public class SecureProperties { @Autowired public void setConfigurableEnvironment(ConfigurableEnvironment env) { try { - Resource resource = new ClassPathResource("/config/secure.properties"); + Resource resource = new ClassPathResource("/config/secure.yml"); env.getPropertySources().addFirst(new PropertiesPropertySource(Objects.requireNonNull(resource.getFilename()), PropertiesLoaderUtils.loadProperties(resource))); } catch (Exception ex) { throw new RuntimeException(ex.getMessage(), ex); diff --git a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java index 49876e7..0f1770c 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java +++ b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java @@ -17,10 +17,7 @@ import org.springframework.util.StopWatch; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; @@ -42,7 +39,8 @@ public class LibraryService { public List getGameFiles() { List gamefiles = new ArrayList<>(); - libraryFolders.parallelStream().map(Path::of).forEach(folder -> { + libraryFolders.parallelStream().map(Path::of).forEach( + folder -> { try (Stream stream = Files.list(folder)) { // return all sub-folders (non-recursive) and files that have an extension that indicates that they are a downloadable file List gameFilesFromThisFolder = stream.filter(p -> Files.isDirectory(p) || hasGameArchiveExtension(p)).toList(); diff --git a/backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000..41bd021 --- /dev/null +++ b/backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,9 @@ +{ + "properties": [ + { + "name": "gameyfin.root", + "type": "java.lang.String[]", + "description": "List of directories Gameyfin should scan for games." + } + ] +} \ No newline at end of file diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml index 30efaba..37e7822 100644 --- a/backend/src/main/resources/application-dev.yml +++ b/backend/src/main/resources/application-dev.yml @@ -1,8 +1,6 @@ gameyfin: user: admin password: password - cache: ${gameyfin.root}\.gameyfin\cache - db: ${gameyfin.root}\.gameyfin\db logging: level: diff --git a/backend/src/main/resources/config/database.properties b/backend/src/main/resources/config/database.properties deleted file mode 100644 index 6123b15..0000000 --- a/backend/src/main/resources/config/database.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file contains properties related to the database configuration -# -# -spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true -spring.datasource.db-name=gameyfin_db -spring.datasource.url=jdbc:h2:file:${gameyfin.db}/${spring.datasource.db-name} -spring.datasource.username=gfadmin -spring.datasource.password=gameyfin -spring.datasource.driverClassName=org.h2.Driver -spring.jpa.database-platform=org.hibernate.dialect.H2Dialect -spring.jpa.hibernate.ddl-auto=update -spring.jpa.open-in-view=true -spring.jpa.properties.hibernate.event.merge.entity_copy_observer=allow \ No newline at end of file diff --git a/backend/src/main/resources/config/database.yml b/backend/src/main/resources/config/database.yml new file mode 100644 index 0000000..7c473a2 --- /dev/null +++ b/backend/src/main/resources/config/database.yml @@ -0,0 +1,18 @@ +spring: + jpa: + open-in-view: 'true' + properties: + hibernate: + enable_lazy_load_no_trans: 'true' + event: + merge: + entity_copy_observer: allow + database-platform: org.hibernate.dialect.H2Dialect + hibernate: + ddl-auto: update + datasource: + username: gfadmin + url: jdbc:h2:file:${gameyfin.db}/${spring.datasource.db-name} + driverClassName: org.h2.Driver + db-name: gameyfin_db + password: gameyfin \ No newline at end of file diff --git a/backend/src/main/resources/config/gameyfin.properties b/backend/src/main/resources/config/gameyfin.properties deleted file mode 100644 index 776836d..0000000 --- a/backend/src/main/resources/config/gameyfin.properties +++ /dev/null @@ -1,28 +0,0 @@ -# This file contains properties related to the configuration of Gameyfin -# -# -# Username and password for the web interface -gameyfin.user= -gameyfin.password= - -# Root folder of your game library -gameyfin.root= -# Folders where gameyfin will store cached images and the database -gameyfin.cache=${gameyfin.root}/.gameyfin/cache -gameyfin.db=${gameyfin.root}/.gameyfin/db - -# File extensions which gameyfin will recognize as game files -gameyfin.file-extensions=iso, zip, rar, 7z, exe - -# List of IGDB platform enums to limit search results. For possible values see: https://api-docs.igdb.com/#platform -gameyfin.igdb.config.preferred-platforms=6 - -# Twitch Client ID and Client Secret -gameyfin.igdb.api.client-id= -gameyfin.igdb.api.client-secret= - -# The IGDB API has a rate limit of 4 req/s -gameyfin.igdb.api.max-requests-per-second=4 - -# According to the docs, there is a maximum of 8 concurrent requests, but in my tests the actual limit was 4 and even then it sometimes failed, so I set it to 2 to be sure -gameyfin.igdb.api.max-concurrent-requests=2 \ No newline at end of file diff --git a/backend/src/main/resources/config/gameyfin.yml b/backend/src/main/resources/config/gameyfin.yml new file mode 100644 index 0000000..ec97065 --- /dev/null +++ b/backend/src/main/resources/config/gameyfin.yml @@ -0,0 +1,19 @@ +gameyfin: + user: + password: + + root: //NAS-Simon/Öffentlich/Spiele, C:/gameyfin-library + + db: ./.gameyfin/db + cache: ./.gameyfin/cache + + file-extensions: iso, zip, rar, 7z, exe + + igdb: + api: + client-id: + client-secret: + max-concurrent-requests: 2 + max-requests-per-second: 4 + config: + preferred-platforms: 6 \ No newline at end of file diff --git a/backend/src/main/resources/config/secure.properties b/backend/src/main/resources/config/secure.properties deleted file mode 100644 index cda7c4e..0000000 --- a/backend/src/main/resources/config/secure.properties +++ /dev/null @@ -1,19 +0,0 @@ -# This file contains properties that are *NOT* safe to override by the user -# In theory a user should not be able to override them since they will be loaded from the classpath at launch, overriding existing user properties with the same key -# -# -# System Info -application.name=Gameyfin -application.version=@project.version@ -# API -server.servlet.context-path=/ -# Spring Actuator -management.endpoints.enabled-by-default=false -management.endpoint.health.enabled=true -# Server -server.error.include-stacktrace=never -spring.mvc.async.request-timeout=-1 -# Jackson JSON Mapping -spring.jackson.default-property-inclusion=non_null -spring.jackson.mapper.accept-case-insensitive-enums=true -spring.jackson.deserialization.fail-on-unknown-properties=false diff --git a/backend/src/main/resources/config/secure.yml b/backend/src/main/resources/config/secure.yml new file mode 100644 index 0000000..cf80710 --- /dev/null +++ b/backend/src/main/resources/config/secure.yml @@ -0,0 +1,27 @@ +application: + version: '@project.version@' + name: Gameyfin + +server: + servlet: + context-path: / + error: + include-stacktrace: never + +spring: + jackson: + deserialization: + fail-on-unknown-properties: false + default-property-inclusion: non_null + mapper: + accept-case-insensitive-enums: true + mvc: + async: + request-timeout: -1 + +management: + endpoint: + health: + enabled: true + endpoints: + enabled-by-default: false \ No newline at end of file diff --git a/docker/docker-compose.example.yml b/docker/docker-compose.example.yml index 265152c..5c2e439 100644 --- a/docker/docker-compose.example.yml +++ b/docker/docker-compose.example.yml @@ -8,6 +8,10 @@ services: - gameyfin.password= - gameyfin.igdb.api.client-id= - gameyfin.igdb.api.client-secret= + # The following two environment variables only need to be set if you have more than one library folder. + # If you have just one you can safely delete them. + - gameyfin.cache=/.gameyfin/cache + - gameyfin.db=/.gameyfin/db volumes: - :/opt/gameyfin-library ports: From da8e075cfc8be424ff0ef6cc3de055064dd366aa Mon Sep 17 00:00:00 2001 From: grimsi <9295182+grimsi@users.noreply.github.com> Date: Fri, 12 Aug 2022 23:37:47 +0200 Subject: [PATCH 3/6] Removed default value from gameyfin.yml --- backend/src/main/resources/config/gameyfin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/resources/config/gameyfin.yml b/backend/src/main/resources/config/gameyfin.yml index ec97065..68089f9 100644 --- a/backend/src/main/resources/config/gameyfin.yml +++ b/backend/src/main/resources/config/gameyfin.yml @@ -2,7 +2,7 @@ gameyfin: user: password: - root: //NAS-Simon/Öffentlich/Spiele, C:/gameyfin-library + root: db: ./.gameyfin/db cache: ./.gameyfin/cache From 7a3a323212a2bf18073b8b34f8b66c3381552c4f Mon Sep 17 00:00:00 2001 From: Simon Grimme <9295182+grimsi@users.noreply.github.com> Date: Sat, 13 Aug 2022 11:19:36 +0200 Subject: [PATCH 4/6] [untested] Set db and cache path from first library root --- ...cureProperties.java => CustomConfiguratioLoader.java} | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) rename backend/src/main/java/de/grimsi/gameyfin/config/{SecureProperties.java => CustomConfiguratioLoader.java} (64%) diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java b/backend/src/main/java/de/grimsi/gameyfin/config/CustomConfiguratioLoader.java similarity index 64% rename from backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java rename to backend/src/main/java/de/grimsi/gameyfin/config/CustomConfiguratioLoader.java index 3140b37..467435f 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java +++ b/backend/src/main/java/de/grimsi/gameyfin/config/CustomConfiguratioLoader.java @@ -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) { From ba4568cb35fd26f47aed9ad55418e0b30b25a96c Mon Sep 17 00:00:00 2001 From: grimsi <9295182+grimsi@users.noreply.github.com> Date: Sat, 13 Aug 2022 12:43:51 +0200 Subject: [PATCH 5/6] Set db and cache path from first library root --- .../gameyfin/config/FilesystemConfig.java | 66 +++++++++++++++++++ ...ratioLoader.java => SecureProperties.java} | 9 +-- .../gameyfin/service/LibraryService.java | 2 +- .../src/main/resources/config/database.yml | 10 +-- .../src/main/resources/config/gameyfin.yml | 9 --- docker/docker-compose.example.yml | 4 -- 6 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java rename backend/src/main/java/de/grimsi/gameyfin/config/{CustomConfiguratioLoader.java => SecureProperties.java} (64%) diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java b/backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java new file mode 100644 index 0000000..2c7aa59 --- /dev/null +++ b/backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java @@ -0,0 +1,66 @@ +package de.grimsi.gameyfin.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.env.*; +import org.springframework.util.PropertyPlaceholderHelper; + +import javax.sql.DataSource; +import java.util.Arrays; +import java.util.Properties; +import java.util.stream.StreamSupport; + +@Configuration +public class FilesystemConfig { + + @Value("#{'${gameyfin.root}'.split(',')[0]}") + private String firstLibraryPath; + + @Autowired + Environment env; + + @Autowired + public void setConfigurableEnvironment(ConfigurableEnvironment env) { + 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("gameyfinFilesystemProperties", props)); + } + + /** + * This bean is needed so Spring initializes the data source after we are done messing with the configuration environment + * @return DataSource + */ + @ConfigurationProperties(prefix = "spring.datasource") + @Bean + @Primary + public DataSource getDataSource() { + + Properties properties = loadAllProperties(); + + return DataSourceBuilder + .create() + .url(properties.getProperty("spring.datasource.url")) + .build(); + } + + private Properties loadAllProperties() { + Properties props = new Properties(); + + MutablePropertySources propSrcs = ((AbstractEnvironment) env).getPropertySources(); + + StreamSupport.stream(propSrcs.spliterator(), false) + .filter(ps -> ps instanceof EnumerablePropertySource) + .map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()) + .flatMap(Arrays::stream) + .forEach(propName -> props.setProperty(propName, env.getProperty(propName))); + + return props; + } + +} diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/CustomConfiguratioLoader.java b/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java similarity index 64% rename from backend/src/main/java/de/grimsi/gameyfin/config/CustomConfiguratioLoader.java rename to backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java index 467435f..3140b37 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/config/CustomConfiguratioLoader.java +++ b/backend/src/main/java/de/grimsi/gameyfin/config/SecureProperties.java @@ -9,20 +9,13 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.PropertiesLoaderUtils; import java.util.Objects; -import java.util.Properties; @Configuration -public class CustomConfiguratioLoader { +public class SecureProperties { @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) { diff --git a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java index 0f1770c..c0e1efd 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java +++ b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java @@ -39,7 +39,7 @@ public class LibraryService { public List getGameFiles() { List gamefiles = new ArrayList<>(); - libraryFolders.parallelStream().map(Path::of).forEach( + libraryFolders.stream().map(Path::of).forEach( folder -> { try (Stream stream = Files.list(folder)) { // return all sub-folders (non-recursive) and files that have an extension that indicates that they are a downloadable file diff --git a/backend/src/main/resources/config/database.yml b/backend/src/main/resources/config/database.yml index 7c473a2..0e02ae7 100644 --- a/backend/src/main/resources/config/database.yml +++ b/backend/src/main/resources/config/database.yml @@ -1,9 +1,9 @@ spring: jpa: - open-in-view: 'true' + open-in-view: true properties: hibernate: - enable_lazy_load_no_trans: 'true' + enable_lazy_load_no_trans: true event: merge: entity_copy_observer: allow @@ -12,7 +12,7 @@ spring: ddl-auto: update datasource: username: gfadmin - url: jdbc:h2:file:${gameyfin.db}/${spring.datasource.db-name} - driverClassName: org.h2.Driver + password: gameyfin db-name: gameyfin_db - password: gameyfin \ No newline at end of file + url: jdbc:h2:file:${gameyfin.db}/${spring.datasource.db-name} + driverClassName: org.h2.Driver \ No newline at end of file diff --git a/backend/src/main/resources/config/gameyfin.yml b/backend/src/main/resources/config/gameyfin.yml index 68089f9..f70079e 100644 --- a/backend/src/main/resources/config/gameyfin.yml +++ b/backend/src/main/resources/config/gameyfin.yml @@ -1,14 +1,5 @@ gameyfin: - user: - password: - - root: - - db: ./.gameyfin/db - cache: ./.gameyfin/cache - file-extensions: iso, zip, rar, 7z, exe - igdb: api: client-id: diff --git a/docker/docker-compose.example.yml b/docker/docker-compose.example.yml index 5c2e439..265152c 100644 --- a/docker/docker-compose.example.yml +++ b/docker/docker-compose.example.yml @@ -8,10 +8,6 @@ services: - gameyfin.password= - gameyfin.igdb.api.client-id= - gameyfin.igdb.api.client-secret= - # The following two environment variables only need to be set if you have more than one library folder. - # If you have just one you can safely delete them. - - gameyfin.cache=/.gameyfin/cache - - gameyfin.db=/.gameyfin/db volumes: - :/opt/gameyfin-library ports: From c3de83c6b92d369c295e1a0081b50aa45564c99b Mon Sep 17 00:00:00 2001 From: grimsi <9295182+grimsi@users.noreply.github.com> Date: Sat, 13 Aug 2022 16:34:56 +0200 Subject: [PATCH 6/6] Renamed "gameyfin.root" to "gameyfin.sources" --- .../java/de/grimsi/gameyfin/config/FilesystemConfig.java | 2 +- .../java/de/grimsi/gameyfin/service/LibraryService.java | 3 +-- .../META-INF/additional-spring-configuration-metadata.json | 2 +- docker/Dockerfile | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java b/backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java index 2c7aa59..5b9cf98 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java +++ b/backend/src/main/java/de/grimsi/gameyfin/config/FilesystemConfig.java @@ -18,7 +18,7 @@ import java.util.stream.StreamSupport; @Configuration public class FilesystemConfig { - @Value("#{'${gameyfin.root}'.split(',')[0]}") + @Value("#{'${gameyfin.sources}'.split(',')[0]}") private String firstLibraryPath; @Autowired diff --git a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java index c0e1efd..f5c7308 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java +++ b/backend/src/main/java/de/grimsi/gameyfin/service/LibraryService.java @@ -29,9 +29,8 @@ import static de.grimsi.gameyfin.util.FilenameUtil.hasGameArchiveExtension; @RequiredArgsConstructor public class LibraryService { - @Value("${gameyfin.root}") + @Value("${gameyfin.sources}") private List libraryFolders; - private final IgdbWrapper igdbWrapper; private final DetectedGameRepository detectedGameRepository; private final UnmappableFileRepository unmappableFileRepository; diff --git a/backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 41bd021..e346e41 100644 --- a/backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/backend/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1,7 +1,7 @@ { "properties": [ { - "name": "gameyfin.root", + "name": "gameyfin.sources", "type": "java.lang.String[]", "description": "List of directories Gameyfin should scan for games." } diff --git a/docker/Dockerfile b/docker/Dockerfile index c6077b7..743516b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,10 +1,10 @@ FROM openjdk:18 -ENV GAMEYFIN_ROOT=/opt/gameyfin-library +ENV GAMEYFIN_SOURCES=/opt/gameyfin-library RUN groupadd gameyfin && useradd gameyfin -g gameyfin && \ - mkdir -p /opt/gameyfin ${GAMEYFIN_ROOT} && \ - chown -R gameyfin:gameyfin /opt/gameyfin ${GAMEYFIN_ROOT} + mkdir -p /opt/gameyfin ${GAMEYFIN_SOURCES} && \ + chown -R gameyfin:gameyfin /opt/gameyfin ${GAMEYFIN_SOURCES} USER gameyfin:gameyfin