Skip to content

Commit

Permalink
config
Browse files Browse the repository at this point in the history
  • Loading branch information
tksmly committed May 5, 2023
1 parent b50e331 commit f0ee4d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions quick_backup_multi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,18 @@ def get_backup_file_name(backup_format: BackupFormat):
COW_COPY_LIMIT = 2**30 # 1GB / need int, may overflow, so cannot copy files larger than 2GB in a single pass
#copy using "Copy On Write"
def _cpcow(src_path: str, dst_path: str):
if not copy_file_range_supported:
if not copy_file_range_supported or not config.copy_on_write:
return shutil.copy2(src_path, dst_path)

if os.path.isdir(dst_path):
dst_path = os.path.join(dst_path, os.path.basename(src_path))

try:
with open(src_path,'rb') as f11, open(dst_path,'wb+') as f21:
f1 = f11.fileno()
f2 = f21.fileno()
size = os.path.getsize(src_path)
for i in range(0, size, COW_COPY_LIMIT):
os.copy_file_range(f1, f2, COW_COPY_LIMIT, i)
with open(src_path,'rb') as fsrc, open(dst_path,'wb+') as fdst:
while os.copy_file_range(fsrc.fileno(), fdst.fileno(), COW_COPY_LIMIT):
pass


except Exception as e:
server_inst.logger.warning(str(e) + '({} -> {})'.format(src_path, src_path, dst_path) + ",Retry with other functions")
shutil.copy(src_path, dst_path)
Expand Down
1 change: 1 addition & 0 deletions quick_backup_multi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SlotInfo(Serializable):
class Configuration(Serializable):
size_display: bool = True
turn_off_auto_save: bool = True
copy_on_write: bool = False
ignored_files: List[str] = [
'session.lock'
]
Expand Down

0 comments on commit f0ee4d2

Please sign in to comment.