MCPcopy
hub / github.com/dlt-hub/dlt / move_atomic_to_file

Method move_atomic_to_file

dlt/common/storages/file_storage.py:54–69  ·  view source on GitHub ↗
(source_file_path: str, dest_file_path: str)

Source from the content-addressed store, hash-verified

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:

Callers 2

move_atomic_to_folderMethod · 0.80
atomic_importMethod · 0.80

Calls 2

uniq_idFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected