Explorar el Código

ota_完善文件删除功能_3

locky hace 4 años
padre
commit
14578bbea7
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  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)
         if not own_perm:
             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():
             return response.json(173)
         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)
             equipment_version.delete()
         except Exception as e: