This commit is contained in:
dami
2026-07-06 20:32:36 +08:00
parent 6a6f6e6062
commit b88ea7aa3c
2 changed files with 7 additions and 6 deletions
+1 -6
View File
@@ -44,11 +44,6 @@ def getGlobalConf():
result = json.loads(content)
return result
def fastCopy(src, dst, buffer_size=128 * 1024 * 1024): # 128MB 缓冲区
with open(src, 'rb') as fsrc:
with open(dst, 'wb') as fdst:
shutil.copyfileobj(fsrc, fdst, length=buffer_size)
def pSqliteDb(dbname='web_logs', site_name='unset', fn="logs"):
db_dir = getServerDir() + '/logs/' + site_name
if not os.path.exists(db_dir):
@@ -121,7 +116,7 @@ def migrateSiteHotLogs(site_name, query_date):
time.sleep(1)
copy_start = time.time()
# shutil.copy(hot_db, hot_db_tmp)
fastCopy(hot_db, hot_db_tmp, 512 * 1024 * 1024)
mw.fastCopy(hot_db, hot_db_tmp, 512 * 1024 * 1024)
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!")
+6
View File
@@ -25,6 +25,7 @@ import subprocess
import glob
import base64
import re
import shutil
from random import Random
@@ -318,6 +319,11 @@ def toSize(size, middle='') -> str:
s = u
return str(round(size, 2)) + middle + u
def fastCopy(src, dst, buffer_size=128 * 1024 * 1024): # 128MB 缓冲区
with open(src, 'rb') as fsrc:
with open(dst, 'wb') as fdst:
shutil.copyfileobj(fsrc, fdst, length=buffer_size)
def returnData(status, msg, data=None):
if data is None:
return {'status': status, 'msg': msg}