Fixed some bugs related to the property files

This commit is contained in:
grimsi
2022-08-12 23:36:47 +02:00
parent 763bd63056
commit 63d585b5d6
14 changed files with 90 additions and 70 deletions
+2 -1
View File
@@ -36,4 +36,5 @@ build/
### Custom ###
/data/
/backend/src/main/resources/static/
/docker/docker-compose.yml
/docker/docker-compose.yml
/.gameyfin/
+6
View File
@@ -16,12 +16,16 @@
<properties>
<java.version>18</java.version>
<springdoc-openapi-ui.version>1.6.9</springdoc-openapi-ui.version>
<resilience4j.version>1.7.1</resilience4j.version>
<commons-io.version>2.11.0</commons-io.version>
<commons-compress.version>1.21</commons-compress.version>
<protoc.plugin.version>3.11.4</protoc.plugin.version>
<protobuf-java.version>3.21.3</protobuf-java.version>
<!-- Use older version because the newer versions have problems with non-ASCII characters in properties files (umlauts etc.) -->
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
</properties>
<dependencies>
@@ -140,6 +144,7 @@
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.yaml</include>
<include>**/*.json</include>
<include>**/*.txt</include>
<include>**/*.js</include>
<include>**/*.css</include>
@@ -166,6 +171,7 @@
<!-- Import the compiled frontend -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
<executions>
<execution>
<id>copy-resources</id>
@@ -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);
}
@@ -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);
@@ -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<Path> getGameFiles() {
List<Path> gamefiles = new ArrayList<>();
libraryFolders.parallelStream().map(Path::of).forEach(folder -> {
libraryFolders.parallelStream().map(Path::of).forEach(
folder -> {
try (Stream<Path> 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<Path> gameFilesFromThisFolder = stream.filter(p -> Files.isDirectory(p) || hasGameArchiveExtension(p)).toList();
@@ -0,0 +1,9 @@
{
"properties": [
{
"name": "gameyfin.root",
"type": "java.lang.String[]",
"description": "List of directories Gameyfin should scan for games."
}
]
}
@@ -1,8 +1,6 @@
gameyfin:
user: admin
password: password
cache: ${gameyfin.root}\.gameyfin\cache
db: ${gameyfin.root}\.gameyfin\db
logging:
level:
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+4
View File
@@ -8,6 +8,10 @@ services:
- gameyfin.password=<your password here>
- gameyfin.igdb.api.client-id=<your twitch client-id here>
- gameyfin.igdb.api.client-secret=<your twitch client-secret here>
# 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=<path to your game library>/.gameyfin/cache
- gameyfin.db=<path to your game library>/.gameyfin/db
volumes:
- <path to your game library>:/opt/gameyfin-library
ports: