use shutil.copyfile for shutil.move calls

This commit is contained in:
simon 2022-07-17 07:47:27 +07:00
parent ed9237b69d
commit b406250ae2
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 7 additions and 7 deletions

View File

@ -395,12 +395,12 @@ class VideoDownloader:
for file_str in all_cached:
if vid_dict["youtube_id"] in file_str:
old_file = file_str
old_file_path = os.path.join(cache_dir, "download", old_file)
new_file_path = os.path.join(videos, vid_dict["media_url"])
old_path = os.path.join(cache_dir, "download", old_file)
new_path = os.path.join(videos, vid_dict["media_url"])
# move media file and fix permission
shutil.move(old_file_path, new_file_path, copy_function=shutil.copy)
shutil.move(old_path, new_path, copy_function=shutil.copyfile)
if host_uid and host_gid:
os.chown(new_file_path, host_uid, host_gid)
os.chown(new_path, host_uid, host_gid)
@staticmethod
def _delete_from_pending(youtube_id):

View File

@ -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, copy_function=shutil.copy)
shutil.move(video_path, dest_path, copy_function=shutil.copyfile)
else:
print(f"processing with ffmpeg: {video_file}")
new_file = video_file + ".mp4"

View File

@ -305,9 +305,9 @@ class ChannelUrlFixer:
"""fix filepath"""
print(f"{self.youtube_id}: fixing channel rename.")
cache_dir = self.config["application"]["cache_dir"]
new_file_path = os.path.join(
new_path = os.path.join(
cache_dir, "download", self.youtube_id + ".mp4"
)
shutil.move(video_path_is, new_file_path, copy_function=shutil.copy)
shutil.move(video_path_is, new_path, copy_function=shutil.copyfile)
VideoDownloader().move_to_archive(self.video.json_data)
self.video.update_media_url()