@@ -39,44 +39,43 @@ class FileCodes(Model):
3939 created_at : Optional [datetime ] = fields .DatetimeField (
4040 auto_now_add = True , description = "创建时间"
4141 )
42+ #
43+ # file_hash = fields.CharField(
44+ # max_length=128, # SHA-256需要64字符,这里预留扩展空间
45+ # description="文件哈希值",
46+ # unique=True,
47+ # null=True # 允许旧数据为空
48+ # )
49+ # hash_algorithm = fields.CharField(
50+ # max_length=20,
51+ # description="哈希算法类型",
52+ # null=True,
53+ # default="sha256"
54+ # )
4255
43- file_hash = fields .CharField (
44- max_length = 128 , # SHA-256需要64字符,这里预留扩展空间
45- description = "文件哈希值" ,
46- unique = True ,
47- null = True # 允许旧数据为空
48- )
49- hash_algorithm = fields .CharField (
50- max_length = 20 ,
51- description = "哈希算法类型" ,
52- null = True ,
53- default = "sha256"
54- )
55-
56- class FileCodes (Model ):
57- # 新增分片字段
58- chunk_size = fields .IntField (
59- description = "分片大小(字节)" ,
60- default = 0
61- )
62- total_chunks = fields .IntField (
63- description = "总分片数" ,
64- default = 0
65- )
66- uploaded_chunks = fields .IntField (
67- description = "已上传分片数" ,
68- default = 0
69- )
70- upload_status = fields .CharField (
71- max_length = 20 ,
72- description = "上传状态" ,
73- default = "pending" , # pending/in_progress/completed
74- choices = ["pending" , "in_progress" , "completed" ]
75- )
76- is_chunked = fields .BooleanField (
77- description = "是否分片上传" ,
78- default = False
79- )
56+ # # 新增分片字段
57+ # chunk_size = fields.IntField(
58+ # description="分片大小(字节)",
59+ # default=0
60+ # )
61+ # total_chunks = fields.IntField(
62+ # description="总分片数",
63+ # default=0
64+ # )
65+ # uploaded_chunks = fields.IntField(
66+ # description="已上传分片数",
67+ # default=0
68+ # )
69+ # upload_status = fields.CharField(
70+ # max_length=20,
71+ # description="上传状态",
72+ # default="pending", # pending/in_progress/completed
73+ # choices=["pending", "in_progress", "completed"]
74+ # )
75+ # is_chunked = fields.BooleanField(
76+ # description="是否分片上传",
77+ # default=False
78+ # )
8079
8180 async def is_expired (self ):
8281 # 按时间
@@ -92,29 +91,30 @@ async def get_file_path(self):
9291 return f"{ self .file_path } /{ self .uuid_file_name } "
9392
9493
95- class FileChunks (Model ):
96- id = fields .IntField (pk = True )
97- file_code = fields .ForeignKeyField (
98- "models.FileCodes" ,
99- related_name = "chunks" ,
100- on_delete = fields .CASCADE
101- )
102- chunk_number = fields .IntField (description = "分片序号" )
103- chunk_hash = fields .CharField (
104- max_length = 128 ,
105- description = "分片哈希校验值"
106- )
107- chunk_path = fields .CharField (
108- max_length = 255 ,
109- description = "分片存储路径"
110- )
111- created_at = fields .DatetimeField (
112- auto_now_add = True ,
113- description = "上传时间"
114- )
115-
116- class Meta :
117- unique_together = [("file_code" , "chunk_number" )]
94+ #
95+ # class FileChunks(Model):
96+ # id = fields.IntField(pk=True)
97+ # file_code = fields.ForeignKeyField(
98+ # "models.FileCodes",
99+ # related_name="chunks",
100+ # on_delete=fields.CASCADE
101+ # )
102+ # chunk_number = fields.IntField(description="分片序号")
103+ # chunk_hash = fields.CharField(
104+ # max_length=128,
105+ # description="分片哈希校验值"
106+ # )
107+ # chunk_path = fields.CharField(
108+ # max_length=255,
109+ # description="分片存储路径"
110+ # )
111+ # created_at = fields.DatetimeField(
112+ # auto_now_add=True,
113+ # description="上传时间"
114+ # )
115+ #
116+ # class Meta:
117+ # unique_together = [("file_code", "chunk_number")]
118118
119119
120120class KeyValue (Model ):
0 commit comments