(source_file_path: str, dest_file_path: str)
| 52 | |
| 53 | @staticmethod |
| 54 | def move_atomic_to_file(source_file_path: str, dest_file_path: str) -> str: |
| 55 | try: |
| 56 | os.rename(source_file_path, dest_file_path) |
| 57 | except OSError: |
| 58 | # copy to local temp file |
| 59 | folder_name = os.path.dirname(dest_file_path) |
| 60 | dest_temp_file = os.path.join(folder_name, uniq_id()) |
| 61 | try: |
| 62 | shutil.copyfile(source_file_path, dest_temp_file) |
| 63 | os.rename(dest_temp_file, dest_file_path) |
| 64 | os.unlink(source_file_path) |
| 65 | except Exception: |
| 66 | if os.path.isfile(dest_temp_file): |
| 67 | os.remove(dest_temp_file) |
| 68 | raise |
| 69 | return dest_file_path |
| 70 | |
| 71 | @staticmethod |
| 72 | def copy_atomic_to_file(source_file_path: str, dest_file_path: str) -> str: |
no test coverage detected