Skip to content

Commit fb1d301

Browse files
authored
Merge pull request #118 from zurdi15/develop
v1.6.1
2 parents 29d4bd8 + 4529073 commit fb1d301

142 files changed

Lines changed: 58 additions & 42 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/src/config/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
DEV_HOST: str = "0.0.0.0"
88

99
# PATHS
10-
LIBRARY_BASE_PATH: str = "/library"
10+
LIBRARY_BASE_PATH: str = "/romm/library"
11+
ROMM_USER_CONFIG_PATH: str = "/romm/config.yml"
12+
SQLITE_DB_BASE_PATH: str = "/romm/database"
1113
HIGH_PRIO_STRUCTURE_PATH: str = f"{LIBRARY_BASE_PATH}/roms"
12-
ROMM_USER_CONFIG_PATH: str = f"/romm/config.yml"
13-
14-
# ROMM RESERVED FOLDERS
15-
RESERVED_FOLDERS: list = ['resources', 'database']
14+
RESOURCES_BASE_PATH: str = "/romm/resources"
1615

1716
# DEFAULT RESOURCES
1817
DEFAULT_URL_COVER_L: str = "https://images.igdb.com/igdb/image/upload/t_cover_big/nocover.png"
19-
DEFAULT_PATH_COVER_L: str = f"/assets/library/resources/default/cover_l.png"
18+
DEFAULT_PATH_COVER_L: str = f"{RESOURCES_BASE_PATH}/default/cover_l.png"
2019
DEFAULT_URL_COVER_S: str = "https://images.igdb.com/igdb/image/upload/t_cover_small/nocover.png"
21-
DEFAULT_PATH_COVER_S: str = f"/assets/library/resources/default/cover_s.png"
20+
DEFAULT_PATH_COVER_S: str = f"{RESOURCES_BASE_PATH}/default/cover_s.png"
2221

2322
# IGDB
2423
CLIENT_ID: str = os.getenv('CLIENT_ID')

backend/src/config/config_loader.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from urllib.parse import quote_plus
44

5-
from config import ROMM_DB_DRIVER, SUPPORTED_DB_DRIVERS, LIBRARY_BASE_PATH
5+
from config import ROMM_DB_DRIVER, SUPPORTED_DB_DRIVERS, SQLITE_DB_BASE_PATH
66
from logger.logger import log
77

88

@@ -23,9 +23,8 @@ def get_db_engine():
2323
return f"mariadb+mariadbconnector://{DB_USER}:%s@{DB_HOST}:{DB_PORT}/{DB_NAME}" % quote_plus(DB_PASSWD)
2424

2525
elif ROMM_DB_DRIVER == 'sqlite':
26-
SQLITE_PATH: str = f"{LIBRARY_BASE_PATH}/database"
27-
if not os.path.exists(SQLITE_PATH): os.makedirs(SQLITE_PATH)
28-
return f"sqlite:////{SQLITE_PATH}/romm.db"
26+
if not os.path.exists(SQLITE_DB_BASE_PATH): os.makedirs(SQLITE_DB_BASE_PATH)
27+
return f"sqlite:////{SQLITE_DB_BASE_PATH}/romm.db"
2928

3029
else:
3130
log.critical(f"Not supported {ROMM_DB_DRIVER} database")

backend/src/utils/fs.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import requests
77
from fastapi import HTTPException
88

9-
from config import user_config, LIBRARY_BASE_PATH, HIGH_PRIO_STRUCTURE_PATH, RESERVED_FOLDERS, DEFAULT_URL_COVER_L, DEFAULT_PATH_COVER_L, DEFAULT_URL_COVER_S, DEFAULT_PATH_COVER_S
10-
from models.platform import Platform
11-
from models.rom import Rom
9+
from config import user_config, LIBRARY_BASE_PATH, HIGH_PRIO_STRUCTURE_PATH, RESOURCES_BASE_PATH, DEFAULT_URL_COVER_L, DEFAULT_PATH_COVER_L, DEFAULT_URL_COVER_S, DEFAULT_PATH_COVER_S
1210
from handler import dbh
1311
from logger.logger import log
1412

@@ -38,7 +36,6 @@ def get_platforms() -> list[str]:
3836
platforms: list[str] = list(os.walk(f"{LIBRARY_BASE_PATH}/roms"))[0][1]
3937
else:
4038
platforms: list[str] = list(os.walk(LIBRARY_BASE_PATH))[0][1]
41-
[platforms.remove(reserved) for reserved in RESERVED_FOLDERS if reserved in platforms]
4239
try:
4340
excluded_folders: list = user_config['exclude']['folders']
4441
try:
@@ -159,19 +156,19 @@ def _cover_exists(p_slug: str, file_name: str, size: str) -> bool:
159156
Returns
160157
True if cover exists in filesystem else False
161158
"""
162-
logo_path: str = f"{LIBRARY_BASE_PATH}/resources/{p_slug}/{file_name}_{size}.png"
159+
logo_path: str = f"{RESOURCES_BASE_PATH}/{p_slug}/{file_name}_{size}.png"
163160
return True if os.path.exists(logo_path) else False
164161

165162

166163
def _get_cover_path(p_slug: str, file_name: str, size: str) -> str:
167-
"""Returns platform logo filesystem path
164+
"""Returns rom cover filesystem path adapted to frontend folder structure
168165
169166
Args:
170167
p_slug: short name of the platform
171168
file_name: name of rom file
172169
size: size of the cover -> big as 'l' | small as 's'
173170
"""
174-
return f"/assets/library/resources/{p_slug}/{file_name}_{size}.png"
171+
return f"{RESOURCES_BASE_PATH}/{p_slug}/{file_name}_{size}.png"
175172

176173

177174
def _store_cover(p_slug: str, file_name: str, url_cover: str, size: str) -> None:
@@ -184,7 +181,7 @@ def _store_cover(p_slug: str, file_name: str, url_cover: str, size: str) -> None
184181
size: size of the cover -> big as 'l' | small as 's'
185182
"""
186183
cover_file: str = f"{file_name}_{size}.png"
187-
cover_path: str = f"{LIBRARY_BASE_PATH}/resources/{p_slug}/"
184+
cover_path: str = f"{RESOURCES_BASE_PATH}/{p_slug}/"
188185
sizes: dict = {'l': 'big', 's': 'small'}
189186
res = requests.get(url_cover.replace('t_thumb', f't_cover_{sizes[size]}'), stream=True)
190187
if res.status_code == 200:

changelog.md

Lines changed: 23 additions & 13 deletions

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ RUN npm run build
1010
FROM ubuntu/nginx:1.18-22.04_edge as production-stage
1111
COPY --from=front-build-stage /front/dist /var/www/html
1212
COPY ./frontend/assets/platforms /var/www/html/assets/platforms
13-
RUN ln -s /library /var/www/html/assets/library
13+
RUN mkdir -p /var/www/html/assets/romm
14+
RUN ln -s /romm/library /var/www/html/assets/romm/library
15+
RUN ln -s /romm/resources /var/www/html/assets/romm/resources
1416

1517
# setup backend
1618
RUN apt update

docker/docker-compose.example.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ services:
1414
- CLIENT_SECRET=<IGDB client secret>
1515
- STEAMGRIDDB_API_KEY=WIP
1616
volumes:
17-
- '/path/to/library:/library'
17+
- '/path/to/library:/romm/library'
18+
- '/path/to/resources:/romm/resources'
1819
- '/path/to/config.yml:/romm/config.yml'
20+
- '/path/to/database:/romm/database' # Only if ROMM_DB_DRIVER='sqlite' or ROMM_DB_DRIVER not exists
1921
ports:
2022
- '80:80'
2123
depends_on:

docker/init_scripts/init_back

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
cd /back
4-
uvicorn main:app --proxy-headers --host 0.0.0.0 --port 5000 --workers 2
4+
uvicorn main:app --proxy-headers --host 0.0.0.0 --port 5000 --workers 3

frontend/assets/platforms/3ds.ico

264 KB
Binary file not shown.

frontend/assets/platforms/3ds.png

-7.19 KB
Binary file not shown.
264 KB
Binary file not shown.

0 commit comments

Comments
 (0)