feat:New database migration, new adaptation root path configuration
This commit is contained in:
+60
-60
@@ -39,44 +39,43 @@ class FileCodes(Model):
|
|||||||
created_at: Optional[datetime] = fields.DatetimeField(
|
created_at: Optional[datetime] = fields.DatetimeField(
|
||||||
auto_now_add=True, description="创建时间"
|
auto_now_add=True, description="创建时间"
|
||||||
)
|
)
|
||||||
|
#
|
||||||
|
# file_hash = fields.CharField(
|
||||||
|
# max_length=128, # SHA-256需要64字符,这里预留扩展空间
|
||||||
|
# description="文件哈希值",
|
||||||
|
# unique=True,
|
||||||
|
# null=True # 允许旧数据为空
|
||||||
|
# )
|
||||||
|
# hash_algorithm = fields.CharField(
|
||||||
|
# max_length=20,
|
||||||
|
# description="哈希算法类型",
|
||||||
|
# null=True,
|
||||||
|
# default="sha256"
|
||||||
|
# )
|
||||||
|
|
||||||
file_hash = fields.CharField(
|
# # 新增分片字段
|
||||||
max_length=128, # SHA-256需要64字符,这里预留扩展空间
|
# chunk_size = fields.IntField(
|
||||||
description="文件哈希值",
|
# description="分片大小(字节)",
|
||||||
unique=True,
|
# default=0
|
||||||
null=True # 允许旧数据为空
|
# )
|
||||||
)
|
# total_chunks = fields.IntField(
|
||||||
hash_algorithm = fields.CharField(
|
# description="总分片数",
|
||||||
max_length=20,
|
# default=0
|
||||||
description="哈希算法类型",
|
# )
|
||||||
null=True,
|
# uploaded_chunks = fields.IntField(
|
||||||
default="sha256"
|
# description="已上传分片数",
|
||||||
)
|
# default=0
|
||||||
|
# )
|
||||||
class FileCodes(Model):
|
# upload_status = fields.CharField(
|
||||||
# 新增分片字段
|
# max_length=20,
|
||||||
chunk_size = fields.IntField(
|
# description="上传状态",
|
||||||
description="分片大小(字节)",
|
# default="pending", # pending/in_progress/completed
|
||||||
default=0
|
# choices=["pending", "in_progress", "completed"]
|
||||||
)
|
# )
|
||||||
total_chunks = fields.IntField(
|
# is_chunked = fields.BooleanField(
|
||||||
description="总分片数",
|
# description="是否分片上传",
|
||||||
default=0
|
# default=False
|
||||||
)
|
# )
|
||||||
uploaded_chunks = fields.IntField(
|
|
||||||
description="已上传分片数",
|
|
||||||
default=0
|
|
||||||
)
|
|
||||||
upload_status = fields.CharField(
|
|
||||||
max_length=20,
|
|
||||||
description="上传状态",
|
|
||||||
default="pending", # pending/in_progress/completed
|
|
||||||
choices=["pending", "in_progress", "completed"]
|
|
||||||
)
|
|
||||||
is_chunked = fields.BooleanField(
|
|
||||||
description="是否分片上传",
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
async def is_expired(self):
|
async def is_expired(self):
|
||||||
# 按时间
|
# 按时间
|
||||||
@@ -92,29 +91,30 @@ class FileCodes(Model):
|
|||||||
return f"{self.file_path}/{self.uuid_file_name}"
|
return f"{self.file_path}/{self.uuid_file_name}"
|
||||||
|
|
||||||
|
|
||||||
class FileChunks(Model):
|
#
|
||||||
id = fields.IntField(pk=True)
|
# class FileChunks(Model):
|
||||||
file_code = fields.ForeignKeyField(
|
# id = fields.IntField(pk=True)
|
||||||
"models.FileCodes",
|
# file_code = fields.ForeignKeyField(
|
||||||
related_name="chunks",
|
# "models.FileCodes",
|
||||||
on_delete=fields.CASCADE
|
# related_name="chunks",
|
||||||
)
|
# on_delete=fields.CASCADE
|
||||||
chunk_number = fields.IntField(description="分片序号")
|
# )
|
||||||
chunk_hash = fields.CharField(
|
# chunk_number = fields.IntField(description="分片序号")
|
||||||
max_length=128,
|
# chunk_hash = fields.CharField(
|
||||||
description="分片哈希校验值"
|
# max_length=128,
|
||||||
)
|
# description="分片哈希校验值"
|
||||||
chunk_path = fields.CharField(
|
# )
|
||||||
max_length=255,
|
# chunk_path = fields.CharField(
|
||||||
description="分片存储路径"
|
# max_length=255,
|
||||||
)
|
# description="分片存储路径"
|
||||||
created_at = fields.DatetimeField(
|
# )
|
||||||
auto_now_add=True,
|
# created_at = fields.DatetimeField(
|
||||||
description="上传时间"
|
# auto_now_add=True,
|
||||||
)
|
# description="上传时间"
|
||||||
|
# )
|
||||||
class Meta:
|
#
|
||||||
unique_together = [("file_code", "chunk_number")]
|
# class Meta:
|
||||||
|
# unique_together = [("file_code", "chunk_number")]
|
||||||
|
|
||||||
|
|
||||||
class KeyValue(Model):
|
class KeyValue(Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user