From 79996f6838bf3e1200839d4673d18a89920e3473 Mon Sep 17 00:00:00 2001 From: p0358 Date: Sat, 16 Jul 2022 16:54:39 +0200 Subject: [PATCH] Fix permission/mount issues from #268 (#270) * make nginx run as root within the container (#268) * move file to videos path with fallback to regular copy with no metadata copying (#268) * use `copy_function=shutil.copy` everywhere with `shutil.move` --- Dockerfile | 5 ++--- tubearchivist/home/src/download/yt_dlp_handler.py | 2 +- tubearchivist/home/src/index/filesystem.py | 2 +- tubearchivist/home/src/index/reindex.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 19efc8c..0d09add 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,12 +54,11 @@ RUN if [ "$INSTALL_DEBUG" ] ; then \ ; fi # make folders -RUN mkdir /cache -RUN mkdir /youtube -RUN mkdir /app +RUN mkdir /cache /youtube /app # copy config files COPY docker_assets/nginx.conf /etc/nginx/sites-available/default +RUN sed -i 's/^user www\-data\;$/user root\;/' /etc/nginx/nginx.conf # copy application into container COPY ./tubearchivist /app diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index 49db964..383855d 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -398,7 +398,7 @@ class VideoDownloader: old_file_path = os.path.join(cache_dir, "download", old_file) new_file_path = os.path.join(videos, vid_dict["media_url"]) # move media file and fix permission - shutil.move(old_file_path, new_file_path) + shutil.move(old_file_path, new_file_path, copy_function=shutil.copy) if host_uid and host_gid: os.chown(new_file_path, host_uid, host_gid) diff --git a/tubearchivist/home/src/index/filesystem.py b/tubearchivist/home/src/index/filesystem.py index 520be78..1b75db6 100644 --- a/tubearchivist/home/src/index/filesystem.py +++ b/tubearchivist/home/src/index/filesystem.py @@ -266,7 +266,7 @@ class ManualImport: if ext == ".mp4": new_file = video_file + ext dest_path = os.path.join(self.CACHE_DIR, "download", new_file) - shutil.move(video_path, dest_path) + shutil.move(video_path, dest_path, copy_function=shutil.copy) else: print(f"processing with ffmpeg: {video_file}") new_file = video_file + ".mp4" diff --git a/tubearchivist/home/src/index/reindex.py b/tubearchivist/home/src/index/reindex.py index e79ab30..31bf5bc 100644 --- a/tubearchivist/home/src/index/reindex.py +++ b/tubearchivist/home/src/index/reindex.py @@ -304,6 +304,6 @@ class ChannelUrlFixer: new_file_path = os.path.join( cache_dir, "download", self.youtube_id + ".mp4" ) - shutil.move(video_path_is, new_file_path) + shutil.move(video_path_is, new_file_path, copy_function=shutil.copy) VideoDownloader().move_to_archive(self.video.json_data) self.video.update_media_url()