Use forked frontend builds for test admin UI
This commit is contained in:
+30
-1
@@ -1,4 +1,5 @@
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
@@ -8,7 +9,7 @@ from core.response import APIResponse
|
||||
from core.storage import FileStorageInterface, storages
|
||||
from core.settings import settings
|
||||
from core.config import refresh_settings
|
||||
from apps.base.models import FileCodes, KeyValue, file_codes_pydantic
|
||||
from apps.base.models import FileCodes, KeyValue, TransferStats, file_codes_pydantic
|
||||
from apps.base.utils import get_expire_info, get_file_path_name
|
||||
from fastapi import HTTPException
|
||||
from core.settings import data_root
|
||||
@@ -82,6 +83,34 @@ class FileService:
|
||||
return f"{self.FILE_METADATA_KEY_PREFIX}{file_id}"
|
||||
|
||||
async def _delete_file_code(self, file_code: FileCodes):
|
||||
try:
|
||||
name = (
|
||||
f"{file_code.prefix or ''}{file_code.suffix or ''}"
|
||||
or file_code.uuid_file_name
|
||||
or file_code.code
|
||||
)
|
||||
await TransferStats.create(
|
||||
action="delete",
|
||||
file_code_id=file_code.id,
|
||||
code=file_code.code,
|
||||
name=name,
|
||||
size=int(file_code.size or 0),
|
||||
ip="admin-delete",
|
||||
file_path=file_code.file_path or "",
|
||||
expired_at=file_code.expired_at,
|
||||
deleted_at=datetime.now(),
|
||||
meta=json.dumps(
|
||||
{
|
||||
"prefix": file_code.prefix or "",
|
||||
"suffix": file_code.suffix or "",
|
||||
"uuid_file_name": file_code.uuid_file_name or "",
|
||||
"created_at": str(file_code.created_at),
|
||||
},
|
||||
ensure_ascii=False,
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
if file_code.text is None:
|
||||
await self.file_storage.delete_file(file_code)
|
||||
await KeyValue.filter(key=self._file_metadata_key(file_code.id)).delete()
|
||||
|
||||
Reference in New Issue
Block a user