代码拉取完成,页面将自动刷新
import os, sys
import glob
BIG_FILES = ["./backend/libtorch/lib/libtorch.so"]
_BASEDIR = os.path.dirname(os.path.abspath(__file__))
BIG_FILES = [os.path.join(_BASEDIR, _) for _ in BIG_FILES]
FILE_SIZE = 32 * 1024 * 1024
PART_SEP = ".part."
def split(file_path):
if not os.path.exists(file_path):
return
with open(file_path, "rb") as f:
file_data = f.read()
if len(file_data) <= FILE_SIZE:
return
pos = 0
num = 0
while pos < len(file_data):
with open(file_path + PART_SEP + str(num), "wb") as f:
f.write(file_data[pos:pos + FILE_SIZE])
pos += FILE_SIZE
num += 1
os.remove(file_path)
def join(file_path):
if os.path.exists(file_path):
return
file_parts = glob.glob(file_path + PART_SEP + "*")
if len(file_parts) < 1:
return
file_data = bytes()
for num in range(len(file_parts)):
with open(file_path + PART_SEP + str(num), "rb") as f:
file_data += f.read()
with open(file_path, "wb") as f:
f.write(file_data)
for file_part in file_parts:
os.remove(file_part)
if __name__ == '__main__':
for big_file in BIG_FILES:
join(big_file)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。