From fa6d80b10dae10b578d020954d4b9fe79b970077 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 11 Oct 2023 13:43:39 +0100 Subject: [PATCH] Fix OSError by using shutil.move for cross-filesystem moves Using os.rename caused an OSError when trying to move files across different filesystems (e.g., from /tmp to another directory). By using shutil.move, we gracefully handle such situations, ensuring files are moved correctly regardless of the source and destination filesystems. --- laser_encoders/download_models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/laser_encoders/download_models.py b/laser_encoders/download_models.py index 65295162..452501d3 100644 --- a/laser_encoders/download_models.py +++ b/laser_encoders/download_models.py @@ -17,6 +17,7 @@ import argparse import logging import os +import shutil import sys import tempfile from pathlib import Path @@ -67,7 +68,7 @@ def download(self, filename: str): progress_bar.update(len(chunk)) progress_bar.close() - os.rename(temp_file_path, local_file_path) + shutil.move(temp_file_path, local_file_path) def get_language_code(self, language_list: dict, lang: str) -> str: try: