修复应用截图删除,存储未清理问题

pull/5/head
youngS 4 years ago
parent 0dbea33ff3
commit 2d057d46ae
  1. 1
      fir_ser/api/utils/serializer.py
  2. 6
      fir_ser/api/utils/storage/aliyunApi.py
  3. 1
      fir_ser/api/utils/storage/storage.py
  4. 8
      fir_ser/api/utils/utils.py
  5. 5
      fir_ser/api/views/apps.py
  6. 9
      fir_ser/requirements.txt

@ -43,7 +43,6 @@ class UserInfoSerializer(serializers.ModelSerializer):
class Meta:
model = models.UserInfo
# fields="__all__"
# exclude = ["password","is_active","user_permissions","role",]
fields = ["username", "uid", "mobile", "job", "email", "domain_name", "last_login", "first_name",
'head_img', 'storage_active', 'supersign_active']

@ -177,7 +177,11 @@ class AliYunOss(object):
def upload_file(self, local_file_full_path):
if os.path.isfile(local_file_full_path):
self.bucket.put_object_from_file(os.path.basename(local_file_full_path), local_file_full_path)
filename = os.path.basename(local_file_full_path)
headers = {
'Content-Disposition': 'attachment; filename="%s"' % filename
}
self.bucket.put_object_from_file(filename, local_file_full_path, headers)
# with open(local_file_full_path, 'rb') as fileobj:
# # Seek方法用于指定从第1000个字节位置开始读写。上传时会从您指定的第1000个字节位置开始上传,直到文件结束。
# fileobj.seek(1000, os.SEEK_SET)

@ -52,6 +52,7 @@ class Storage(object):
else:
filename = filename + '.ipa'
try:
logger.info("storage %s delete file %s" % (self.storage, filename))
return self.storage.del_file(filename)
except Exception as e:
logger.error("delete file %s failed Exception %s" % (filename, e))

@ -6,7 +6,7 @@
import os, re, json, requests
from fir_ser.settings import SUPER_SIGN_ROOT, SERVER_DOMAIN, CAPTCHA_LENGTH, MEDIA_ROOT
from api.models import APPSuperSignUsedInfo, APPToDeveloper, \
UDIDsyncDeveloper, UserInfo, AppReleaseInfo
UDIDsyncDeveloper, UserInfo, AppReleaseInfo, AppScreenShot
from api.utils.app.randomstrings import make_app_uuid
from api.utils.storage.localApi import LocalStorage
from api.utils.storage.storage import Storage
@ -224,6 +224,12 @@ def delete_local_files(filename, apptype=None):
logger.error("delete file %s failed Exception %s" % (filename, e))
def delete_app_screenshots_files(storage_obj, app_obj):
for screenshot_obj in AppScreenShot.objects.filter(app_id=app_obj).all():
storage_obj.delete_file(screenshot_obj.screenshot_url)
screenshot_obj.delete()
def check_storage_additionalparameter(request, res):
data = request.data
try:

@ -17,7 +17,7 @@ from api.utils.serializer import AppsSerializer, AppReleaseSerializer, UserInfoS
from rest_framework.pagination import PageNumberPagination
import logging
from fir_ser.settings import SERVER_DOMAIN
from api.utils.utils import is_valid_domain, delete_local_files
from api.utils.utils import is_valid_domain, delete_local_files, delete_app_screenshots_files
logger = logging.getLogger(__name__)
@ -149,6 +149,7 @@ class AppInfoView(APIView):
delete_local_files(appreleaseobj.release_id, appreleaseobj.release_type)
storage.delete_file(appreleaseobj.icon_url)
appreleaseobj.delete()
delete_app_screenshots_files(storage, apps_obj)
apps_obj.delete()
return Response(res.dict)
@ -346,7 +347,7 @@ class AppReleaseinfoView(APIView):
del_cache_by_delete_app(apps_obj.app_id)
appreleaseobj.delete()
delete_app_screenshots_files(storage, apps_obj)
has_combo = apps_obj.has_combo
if has_combo:
apps_obj.has_combo.has_combo = None

@ -8,13 +8,15 @@ asgiref==3.2.3
asn1crypto==1.3.0
backcall==0.1.0
bcrypt==3.1.7
biplist==1.0.3
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
Click==7.0
colorama==0.4.3
construct==2.10.61
crcmod==1.7
cryptography==2.9.2
cryptography==3.4.6
cycler==0.10.0
decorator==4.4.2
Django==3.0.3
@ -36,6 +38,7 @@ jmespath==0.9.5
kiwisolver==1.1.0
lxml==4.5.0
matplotlib==3.2.0
memoizer==0.0.1
mysqlclient==1.4.6
networkx==2.4
numpy==1.18.1
@ -47,8 +50,9 @@ pickleshare==0.7.5
Pillow==7.0.0
prompt-toolkit==3.0.3
ptyprocess==0.6.0
pyasn1==0.4.8
pycparser==2.20
pycryptodome==3.9.7
pycryptodome==3.10.1
pydot==1.4.1
Pygments==2.5.2
PyJWT==1.7.1
@ -61,6 +65,7 @@ pytz==2019.3
qiniu==7.2.8
redis==3.4.1
requests==2.23.0
rsa==4.7.2
six==1.14.0
sqlparse==0.3.1
traitlets==4.3.3

Loading…
Cancel
Save