文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 42813969 by 李景熙

修改删除任务功能,使其同时删除保存的文件

parent d7250f00
...@@ -2222,8 +2222,8 @@ ...@@ -2222,8 +2222,8 @@
}, },
"complex.js": { "complex.js": {
"version": "2.0.11", "version": "2.0.11",
"resolved": "https://registry.npm.taobao.org/complex.js/download/complex.js-2.0.11.tgz", "resolved": "https://registry.npmjs.org/complex.js/-/complex.js-2.0.11.tgz",
"integrity": "sha1-Cahz+/Ff/YwYycIgHM70JcMri/E=" "integrity": "sha512-6IArJLApNtdg1P1dFtn3dnyzoZBEF0MwMnrfF1exSBRpZYoy4yieMkpZhQDC0uwctw48vii0CFVyHfpgZ/DfGw=="
}, },
"component-emitter": { "component-emitter": {
"version": "1.3.0", "version": "1.3.0",
...@@ -3538,8 +3538,8 @@ ...@@ -3538,8 +3538,8 @@
}, },
"decimal.js": { "decimal.js": {
"version": "10.2.0", "version": "10.2.0",
"resolved": "https://registry.npm.taobao.org/decimal.js/download/decimal.js-10.2.0.tgz", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.0.tgz",
"integrity": "sha1-OUZhE6ngNhEdAvgkibX9awte0jE=" "integrity": "sha512-vDPw+rDgn3bZe1+F/pyEwb1oMG2XTlRVgAa6B4KccTEpYgF8w6eQllVbQcfIJnZyvzFtFpxnpGtx8dd7DJp/Rw=="
}, },
"decode-uri-component": { "decode-uri-component": {
"version": "0.2.0", "version": "0.2.0",
...@@ -4103,8 +4103,8 @@ ...@@ -4103,8 +4103,8 @@
}, },
"escape-latex": { "escape-latex": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npm.taobao.org/escape-latex/download/escape-latex-1.2.0.tgz", "resolved": "https://registry.npmjs.org/escape-latex/-/escape-latex-1.2.0.tgz",
"integrity": "sha1-B8A4GM99rCUMzlF/T9obAB7yvKE=" "integrity": "sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw=="
}, },
"escape-string-regexp": { "escape-string-regexp": {
"version": "1.0.5", "version": "1.0.5",
...@@ -4998,8 +4998,8 @@ ...@@ -4998,8 +4998,8 @@
}, },
"fraction.js": { "fraction.js": {
"version": "4.0.12", "version": "4.0.12",
"resolved": "https://registry.npm.taobao.org/fraction.js/download/fraction.js-4.0.12.tgz", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.0.12.tgz",
"integrity": "sha1-BSbUfGWl+0hU33i8d/e+xwjXuMM=" "integrity": "sha512-8Z1K0VTG4hzYY7kA/1sj4/r1/RWLBD3xwReT/RCrUCbzPszjNQCCsy3ktkU/eaEqX3MYa4pY37a52eiBlPMlhA=="
}, },
"fragment-cache": { "fragment-cache": {
"version": "0.2.1", "version": "0.2.1",
...@@ -6704,7 +6704,7 @@ ...@@ -6704,7 +6704,7 @@
}, },
"javascript-natural-sort": { "javascript-natural-sort": {
"version": "0.7.1", "version": "0.7.1",
"resolved": "https://registry.npm.taobao.org/javascript-natural-sort/download/javascript-natural-sort-0.7.1.tgz", "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz",
"integrity": "sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k=" "integrity": "sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k="
}, },
"js-base64": { "js-base64": {
...@@ -7069,8 +7069,8 @@ ...@@ -7069,8 +7069,8 @@
}, },
"mathjs": { "mathjs": {
"version": "7.0.2", "version": "7.0.2",
"resolved": "https://registry.npm.taobao.org/mathjs/download/mathjs-7.0.2.tgz?cache=0&sync_timestamp=1592989416336&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmathjs%2Fdownload%2Fmathjs-7.0.2.tgz", "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-7.0.2.tgz",
"integrity": "sha1-8X6uKJqjpd5UPCLAXOMnFWBFRIA=", "integrity": "sha512-+/HTkdie4Sek66mjcclk2cgTyVgFfykutk5PGspbtZHUBbS3lOeiM8/Ax7P6nQlz1KoellFAU/kGO4q7Yv1sZA==",
"requires": { "requires": {
"complex.js": "^2.0.11", "complex.js": "^2.0.11",
"decimal.js": "^10.2.0", "decimal.js": "^10.2.0",
...@@ -11389,7 +11389,7 @@ ...@@ -11389,7 +11389,7 @@
}, },
"seed-random": { "seed-random": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npm.taobao.org/seed-random/download/seed-random-2.2.0.tgz", "resolved": "https://registry.npmjs.org/seed-random/-/seed-random-2.2.0.tgz",
"integrity": "sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ=" "integrity": "sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ="
}, },
"select-hose": { "select-hose": {
...@@ -12359,8 +12359,8 @@ ...@@ -12359,8 +12359,8 @@
}, },
"tiny-emitter": { "tiny-emitter": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npm.taobao.org/tiny-emitter/download/tiny-emitter-2.1.0.tgz", "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
"integrity": "sha1-HRpW7fxRxD6GPLtTgqcjMONVVCM=" "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
}, },
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
...@@ -12506,8 +12506,8 @@ ...@@ -12506,8 +12506,8 @@
}, },
"typed-function": { "typed-function": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npm.taobao.org/typed-function/download/typed-function-1.1.1.tgz?cache=0&sync_timestamp=1593755771661&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftyped-function%2Fdownload%2Ftyped-function-1.1.1.tgz", "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-1.1.1.tgz",
"integrity": "sha1-oTFhh+w2KMniGbkcqWkYZgoQE44=" "integrity": "sha512-RbN7MaTQBZLJYzDENHPA0nUmWT0Ex80KHItprrgbTPufYhIlTePvCXZxyQK7wgn19FW5bnuaBIKcBb5mRWjB1Q=="
}, },
"typedarray": { "typedarray": {
"version": "0.0.6", "version": "0.0.6",
......
import os
from peewee import * from peewee import *
from Dao.model import mysql from Dao.model import mysql
from Dao import Slice from Dao import Slice
from support import basedir
UPLOAD_FOLDER = 'upload'
class Result: class Result:
...@@ -47,7 +52,7 @@ def find_data(id): ...@@ -47,7 +52,7 @@ def find_data(id):
return Result(1, "find success", data.url) return Result(1, "find success", data.url)
# 查找某分片下的文件 # 查找某分片下的文件(用于查看某分片下的文件信息)
def find_data_by_slice(slice_id): def find_data_by_slice(slice_id):
try: try:
find = Data.select(Data.data_id, Data.name, Data.size, Data.url).where( find = Data.select(Data.data_id, Data.name, Data.size, Data.url).where(
...@@ -71,7 +76,7 @@ def find_data_by_slice(slice_id): ...@@ -71,7 +76,7 @@ def find_data_by_slice(slice_id):
return Result(1, "find success", list) return Result(1, "find success", list)
# 查找分片下的文件url列表 # 查找分片下的文件列表(用于修改任务时传回文件信息)
def find_url_by_slice(slice_id): def find_url_by_slice(slice_id):
try: try:
find = Data.select(Data.url, Data.name, Data.size).where( find = Data.select(Data.url, Data.name, Data.size).where(
...@@ -94,6 +99,13 @@ def find_url_by_slice(slice_id): ...@@ -94,6 +99,13 @@ def find_url_by_slice(slice_id):
# 删除某分片下的文件 # 删除某分片下的文件
def delete_data_by_slice(slice_id): def delete_data_by_slice(slice_id):
try: try:
find = Data.select(Data.url).where(Data.slice_id == slice_id)
index = 0
while index < len(find):
file_dir = os.path.join(basedir, UPLOAD_FOLDER, find[index].url)
if os.path.exists(file_dir):
os.remove(file_dir)
index += 1
Data.delete().where(Data.slice_id == slice_id).execute() Data.delete().where(Data.slice_id == slice_id).execute()
except: except:
return Result(0, "delete failed", {}) return Result(0, "delete failed", {})
...@@ -102,4 +114,4 @@ def delete_data_by_slice(slice_id): ...@@ -102,4 +114,4 @@ def delete_data_by_slice(slice_id):
if __name__ == '__main__': if __name__ == '__main__':
Data.create_table() delete_data_by_slice(10)
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment