mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 06:39:25 +08:00
up
This commit is contained in:
@@ -116,9 +116,9 @@ def migrateSiteHotLogs(site_name, query_date):
|
||||
time.sleep(0.5)
|
||||
copy_start = time.time()
|
||||
# import shutil
|
||||
# shutil.copy(hot_db, hot_db_tmp)
|
||||
shutil.copy(hot_db, hot_db_tmp)
|
||||
# mw.fastCopy(hot_db, hot_db_tmp, 256 * 1024)
|
||||
mw.sendfile(hot_db,hot_db_tmp)
|
||||
# mw.sendfile(hot_db,hot_db_tmp)
|
||||
print(f"[{site_name}] 备份完成,耗时 {time.time() - copy_start:.2f}s")
|
||||
if not os.path.exists(hot_db_tmp):
|
||||
return mw.returnMsg(False, f"{site_name} migrating fail, copy tmp file!")
|
||||
|
||||
+15
-5
@@ -327,15 +327,25 @@ def fastCopy(src, dst, buffer_size=256 * 1024): # 128MB 缓冲区
|
||||
# linux高效复制
|
||||
def sendfile(src, dst):
|
||||
if isAppleSystem():
|
||||
shutil.copyfile(src, dst)
|
||||
return True
|
||||
try:
|
||||
shutil.copyfile(src, dst)
|
||||
return True
|
||||
except Exception as e:
|
||||
return False
|
||||
|
||||
try:
|
||||
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
|
||||
filesize = os.fstat(fsrc.fileno()).st_size
|
||||
os.sendfile(fdst.fileno(), fsrc.fileno(), 0, filesize)
|
||||
sent = os.sendfile(fdst.fileno(), fsrc.fileno(), 0, filesize)
|
||||
if sent != filesize:
|
||||
shutil.copyfile(src, dst)
|
||||
return True
|
||||
except OSError as e:
|
||||
return False
|
||||
except (OSError, AttributeError) as e:
|
||||
try:
|
||||
shutil.copyfile(src, dst)
|
||||
return True
|
||||
except Exception as e2:
|
||||
return False
|
||||
|
||||
def returnData(status, msg, data=None):
|
||||
if data is None:
|
||||
|
||||
Reference in New Issue
Block a user