mirror of
https://github.com/rommapp/romm.git
synced 2026-02-17 16:17:40 +01:00
fix issues from code review
This commit is contained in:
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -34,7 +34,7 @@
|
||||
},
|
||||
{
|
||||
"label": "Launch full stack",
|
||||
"dependsOn": ["Launch frontend", "Launch backend", "Launch worker"],
|
||||
"dependsOn": ["Launch frontend", "Launch backend"],
|
||||
"problemMatcher": [],
|
||||
"dependsOrder": "parallel"
|
||||
}
|
||||
|
||||
@@ -140,6 +140,9 @@ add_pagination(app)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run migrations
|
||||
alembic.config.main(argv=["upgrade", "head"])
|
||||
|
||||
# Initialize scheduled tasks
|
||||
if ENABLE_SCHEDULED_RESCAN:
|
||||
log.info("Starting scheduled rescan")
|
||||
@@ -153,9 +156,6 @@ if __name__ == "__main__":
|
||||
log.info("Starting scheduled update launchbox metadata")
|
||||
update_launchbox_metadata_task.init()
|
||||
|
||||
# Run migrations
|
||||
alembic.config.main(argv=["upgrade", "head"])
|
||||
|
||||
# Run application
|
||||
app.add_middleware(CustomLoggingMiddleware)
|
||||
uvicorn.run("main:app", host=DEV_HOST, port=DEV_PORT, reload=True, access_log=False)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
from typing import Literal
|
||||
|
||||
import sentry_sdk
|
||||
from config import (
|
||||
@@ -34,16 +35,23 @@ sentry_sdk.init(
|
||||
|
||||
structure_level = 2 if os.path.exists(cm.get_config().HIGH_PRIO_STRUCTURE_PATH) else 1
|
||||
|
||||
valid_events = [
|
||||
DirCreatedEvent.event_type,
|
||||
DirDeletedEvent.event_type,
|
||||
FileCreatedEvent.event_type,
|
||||
FileDeletedEvent.event_type,
|
||||
FileSystemMovedEvent.event_type,
|
||||
]
|
||||
valid_events = frozenset(
|
||||
(
|
||||
DirCreatedEvent.event_type,
|
||||
DirDeletedEvent.event_type,
|
||||
FileCreatedEvent.event_type,
|
||||
FileDeletedEvent.event_type,
|
||||
FileSystemMovedEvent.event_type,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def on_any_event(src_path: str, _dest_path: str, event_type: str, object: str):
|
||||
def on_any_event(
|
||||
src_path: str,
|
||||
_dest_path: str,
|
||||
event_type: str,
|
||||
fs_obj: Literal["file", "directory"],
|
||||
):
|
||||
if event_type not in valid_events:
|
||||
return
|
||||
|
||||
@@ -74,7 +82,7 @@ def on_any_event(src_path: str, _dest_path: str, event_type: str, object: str):
|
||||
rescan_in_msg = f"rescanning in {hl(str(RESCAN_ON_FILESYSTEM_CHANGE_DELAY), color=CYAN)} minutes."
|
||||
|
||||
# Any change to a platform directory should trigger a full rescan
|
||||
if object == "directory" and event_src.count("/") == 1:
|
||||
if fs_obj == "directory" and event_src.count("/") == 1:
|
||||
log.info(f"Platform directory changed, {rescan_in_msg}")
|
||||
tasks_scheduler.enqueue_in(time_delta, scan_platforms, [])
|
||||
elif db_platform:
|
||||
@@ -94,4 +102,4 @@ if __name__ == "__main__":
|
||||
watch_event_type = sys.argv[3]
|
||||
watch_object = sys.argv[4]
|
||||
|
||||
on_any_event(watch_src_path, watch_dest_path, watch_event_type, watch_object)
|
||||
on_any_event(watch_src_path, watch_dest_path, watch_event_type, watch_object) # type: ignore
|
||||
|
||||
@@ -183,10 +183,10 @@ start_bin_rq_worker() {
|
||||
|
||||
# Build Redis URL properly
|
||||
local redis_url
|
||||
if [[ -n ${REDIS_USERNAME-} && -n ${REDIS_PASSWORD-} ]]; then
|
||||
redis_url="redis${REDIS_SSL:+s}://${REDIS_USERNAME}:${REDIS_PASSWORD}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
elif [[ -n ${REDIS_PASSWORD-} ]]; then
|
||||
redis_url="redis${REDIS_SSL:+s}://:${REDIS_PASSWORD}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
if [[ -n ${REDIS_PASSWORD-} ]]; then
|
||||
redis_url="redis${REDIS_SSL:+s}://${REDIS_USERNAME-}:${REDIS_PASSWORD}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
elif [[ -n ${REDIS_USERNAME-} ]]; then
|
||||
redis_url="redis${REDIS_SSL:+s}://${REDIS_USERNAME}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
else
|
||||
redis_url="redis${REDIS_SSL:+s}://${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
fi
|
||||
|
||||
@@ -51,10 +51,10 @@ RQ_REDIS_HOST=${REDIS_HOST:-127.0.0.1} \
|
||||
|
||||
echo "Starting RQ worker..."
|
||||
# Build Redis URL properly
|
||||
if [[ -n ${REDIS_USERNAME-} && -n ${REDIS_PASSWORD-} ]]; then
|
||||
REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_USERNAME}:${REDIS_PASSWORD}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
elif [[ -n ${REDIS_PASSWORD-} ]]; then
|
||||
REDIS_URL="redis${REDIS_SSL:+s}://:${REDIS_PASSWORD}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
if [[ -n ${REDIS_PASSWORD-} ]]; then
|
||||
REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_USERNAME-}:${REDIS_PASSWORD}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
elif [[ -n ${REDIS_USERNAME-} ]]; then
|
||||
REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_USERNAME}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
else
|
||||
REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
|
||||
fi
|
||||
|
||||
@@ -51,7 +51,7 @@ dependencies = [
|
||||
"user-agents ~= 2.2",
|
||||
"uvicorn ~= 0.35",
|
||||
"uvicorn-worker ~= 0.3",
|
||||
"watchdog ~= 6.0",
|
||||
"watchdog[watchmedo]~=6.0",
|
||||
"yarl ~= 1.14",
|
||||
"zipfile-inflate64 ~= 0.1",
|
||||
]
|
||||
|
||||
11
uv.lock
generated
11
uv.lock
generated
@@ -1,5 +1,5 @@
|
||||
version = 1
|
||||
revision = 3
|
||||
revision = 2
|
||||
requires-python = ">=3.13"
|
||||
resolution-markers = [
|
||||
"platform_python_implementation != 'PyPy'",
|
||||
@@ -1784,7 +1784,7 @@ dependencies = [
|
||||
{ name = "user-agents" },
|
||||
{ name = "uvicorn" },
|
||||
{ name = "uvicorn-worker" },
|
||||
{ name = "watchdog" },
|
||||
{ name = "watchdog", extra = ["watchmedo"] },
|
||||
{ name = "yarl" },
|
||||
{ name = "zipfile-inflate64" },
|
||||
]
|
||||
@@ -1857,7 +1857,7 @@ requires-dist = [
|
||||
{ name = "user-agents", specifier = "~=2.2" },
|
||||
{ name = "uvicorn", specifier = "~=0.35" },
|
||||
{ name = "uvicorn-worker", specifier = "~=0.3" },
|
||||
{ name = "watchdog", specifier = "~=6.0" },
|
||||
{ name = "watchdog", extras = ["watchmedo"], specifier = "~=6.0" },
|
||||
{ name = "yarl", specifier = "~=1.14" },
|
||||
{ name = "zipfile-inflate64", specifier = "~=0.1" },
|
||||
]
|
||||
@@ -2400,6 +2400,11 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/33/e8/e40370e6d74ddba47f002a32919d91310d6074130fe4e17dabcafc15cbf1/watchdog-6.0.0-py3-none-win_ia64.whl", hash = "sha256:a1914259fa9e1454315171103c6a30961236f508b9b623eae470268bbcc6a22f", size = 79067, upload-time = "2024-11-01T14:07:11.845Z" },
|
||||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
watchmedo = [
|
||||
{ name = "pyyaml" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "watchfiles"
|
||||
version = "1.1.0"
|
||||
|
||||
Reference in New Issue
Block a user