Skip to content

Commit

Permalink
Fix OSError by using shutil.move for cross-filesystem moves
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Paulooh007 committed Oct 11, 2023
1 parent c947443 commit fa6d80b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion laser_encoders/download_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import argparse
import logging
import os
import shutil
import sys
import tempfile
from pathlib import Path
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fa6d80b

Please sign in to comment.