|
@@ -3,7 +3,7 @@ import shutil
|
|
import time
|
|
import time
|
|
import traceback
|
|
import traceback
|
|
import os
|
|
import os
|
|
-from urllib import request
|
|
|
|
|
|
+from urllib import request, parse
|
|
|
|
|
|
from django.http import HttpResponse
|
|
from django.http import HttpResponse
|
|
|
|
|
|
@@ -79,15 +79,16 @@ class PcInfo(View):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
else:
|
|
else:
|
|
file = Pc_Info.objects.filter(pc_name=pc_name, bundle_version=bundle_version,
|
|
file = Pc_Info.objects.filter(pc_name=pc_name, bundle_version=bundle_version,
|
|
- pc_version=pc_version)
|
|
|
|
|
|
+ pc_version=pc_version, pc_test=pc_test)
|
|
if file:
|
|
if file:
|
|
return response.json(174)
|
|
return response.json(174)
|
|
try:
|
|
try:
|
|
# 安装包上传到服务器本地
|
|
# 安装包上传到服务器本地
|
|
- file_path = 'static/pc/' + pc_name + '/' + bundle_version + '_' + pc_version + '_' + pc_test
|
|
|
|
|
|
+ file_path = 'static/pc/' + pc_name
|
|
if not os.path.exists(file_path):
|
|
if not os.path.exists(file_path):
|
|
os.makedirs(os.path.join(BASE_DIR, file_path))
|
|
os.makedirs(os.path.join(BASE_DIR, file_path))
|
|
- file_path = file_path + '/' + str(file_name)
|
|
|
|
|
|
+ name = pc_version + '_' + bundle_version + '_' + pc_test + '_' + str(file_name)
|
|
|
|
+ file_path = file_path + '/' + str(name)
|
|
upload_path = os.path.join(BASE_DIR, file_path)
|
|
upload_path = os.path.join(BASE_DIR, file_path)
|
|
print('upload_path:', upload_path)
|
|
print('upload_path:', upload_path)
|
|
with open(upload_path, 'wb+') as destination:
|
|
with open(upload_path, 'wb+') as destination:
|
|
@@ -186,7 +187,7 @@ class PcInfo(View):
|
|
wrapper = FileWrapper(open(fullPath, 'rb'))
|
|
wrapper = FileWrapper(open(fullPath, 'rb'))
|
|
response = HttpResponse(wrapper, content_type="application/octet-stream")
|
|
response = HttpResponse(wrapper, content_type="application/octet-stream")
|
|
response['Content-Length'] = os.path.getsize(fullPath)
|
|
response['Content-Length'] = os.path.getsize(fullPath)
|
|
- response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(fullPath)
|
|
|
|
|
|
+ response['Content-Disposition'] = 'attachment; filename={}'.format(parse.quote_plus(os.path.basename(fullPath), encoding="utf-8"))
|
|
response['Content-MD5'] = getMD5orSHA265(fullPath)
|
|
response['Content-MD5'] = getMD5orSHA265(fullPath)
|
|
# 校验文件md5值
|
|
# 校验文件md5值
|
|
response['Content-SHA265'] = getMD5orSHA265(fullPath, 'SHA265')
|
|
response['Content-SHA265'] = getMD5orSHA265(fullPath, 'SHA265')
|
|
@@ -221,10 +222,10 @@ class PcInfo(View):
|
|
file_path = file[0].download_link
|
|
file_path = file[0].download_link
|
|
file_path = os.path.join(BASE_DIR, file_path).replace('\\', '/')
|
|
file_path = os.path.join(BASE_DIR, file_path).replace('\\', '/')
|
|
os.remove(file_path)
|
|
os.remove(file_path)
|
|
- file_path = file_path.split("/")
|
|
|
|
- file_path = [str(i) for i in file_path][:-1]
|
|
|
|
- file_path = "/".join(file_path)
|
|
|
|
- shutil.rmtree(file_path)
|
|
|
|
|
|
+ # file_path = file_path.split("/")
|
|
|
|
+ # file_path = [str(i) for i in file_path][:-1]
|
|
|
|
+ # file_path = "/".join(file_path)
|
|
|
|
+ # shutil.rmtree(file_path)
|
|
file.delete()
|
|
file.delete()
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(176, repr(e))
|
|
return response.json(176, repr(e))
|