Browse Source

ota_完善文件删除功能_3

locky 4 years ago
parent
commit
14578bbea7
1 changed files with 3 additions and 2 deletions
  1. 3 2
      Controller/EquipmentOTA.py

+ 3 - 2
Controller/EquipmentOTA.py

@@ -70,12 +70,13 @@ class EquipmentOTA(View):
         own_perm = ModelService.check_perm(userID=userID, permID=230)
         own_perm = ModelService.check_perm(userID=userID, permID=230)
         if not own_perm:
         if not own_perm:
             return response.json(404)
             return response.json(404)
-        equipment_version = Equipment_Version.objects.filter(eid=eid, version=version).values('filePath')
+        equipment_version = Equipment_Version.objects.filter(eid=eid, version=version)
         if not equipment_version.exists():
         if not equipment_version.exists():
             return response.json(173)
             return response.json(173)
         try:
         try:
             # 删除文件和相应数据
             # 删除文件和相应数据
-            file_path = '/'.join(BASE_DIR, equipment_version[0]['filePath']).replace('\\', '/')
+            file_path = equipment_version[0].filePath
+            file_path = '/'.join((BASE_DIR, file_path)).replace('\\', '/')
             os.remove(file_path)
             os.remove(file_path)
             equipment_version.delete()
             equipment_version.delete()
         except Exception as e:
         except Exception as e: