Skip to content

Commit 2f8c558

Browse files
committed
fix: adapt after testing in context with old API
1 parent 94cf08b commit 2f8c558

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
upload/
2+
archive/
3+
.venv

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ COPY --from=builder --chown=app:app /app .
3434
# Place executables in the environment at the front of the path
3535
ENV PATH="/app/.venv/bin:$PATH"
3636

37+
USER 1000
38+
3739
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

app/api/hooks/routes.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ async def receive_hook(
3232
# construct updated values for the file info
3333
sanitized_filename = secure_filename(metadata.orig_file_name)
3434
upload_id = f"{metadata.video_id}"
35-
new_file = settings.tusd_dir / f"{upload_id}/{sanitized_filename}"
35+
new_file = Path(f"{upload_id}/{sanitized_filename}")
3636

37-
if new_file.exists():
37+
if (settings.tusd_dir / new_file).exists():
3838
logger.warning("File already exists, deleting!: %s", new_file)
3939
new_file.unlink()
4040

@@ -43,11 +43,8 @@ async def receive_hook(
4343
if hook_request.type == "post-finish":
4444
ingest = Ingester(archive_base_path=settings.archive_dir, django_api=django_api)
4545
upload_meta = get_upload_metadata(hook_request)
46+
upload_file = Path(hook_request.event.upload.storage["Path"])
4647

47-
# As it's presently configured, tusd sees it at /upload/<video_id>/<sanitized_filename>
48-
# and it's mounted at ./upload for ingest.
49-
# It's a janky way to turn an absolute path to a relative one, but it works
50-
upload_file = Path(f".{hook_request.event.upload.storage['Path']}")
5148
try:
5249
metadata = await metadata_extractor.assert_compliance(upload_file)
5350
except ComplianceError as e:

app/util/lifespan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ async def lifespan(app: FastAPI):
4848
# fixme: should only happen in debug mode
4949
from app.api.debug.watch_folder.watcher import start_watchfolder
5050

51-
logger.info("Starting directory watcher for %s", settings.debug.watchdir)
52-
start_watchfolder(settings.debug.watchdir)
51+
logger.info("Starting directory watcher for %s", settings.tusd_dir)
52+
start_watchfolder(settings.tusd_dir)
5353

5454
yield # App runs here
5555

tests/get_git_root.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33

44

55
def get_git_root():
6-
return Path(subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip())
6+
try:
7+
return Path(subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip())
8+
except Exception:
9+
return Path("/app")

0 commit comments

Comments
 (0)