(self, file_id: int)
| 611 | return data |
| 612 | |
| 613 | async def get_file_detail(self, file_id: int): |
| 614 | file_code = await FileCodes.filter(id=file_id).first() |
| 615 | if not file_code: |
| 616 | raise HTTPException(status_code=404, detail="文件不存在") |
| 617 | |
| 618 | now = await get_now() |
| 619 | detail = await self._build_admin_file_item(file_code, now=now) |
| 620 | is_text = file_code.text is not None |
| 621 | has_download_limit = file_code.expired_count >= 0 |
| 622 | is_permanent = file_code.expired_at is None and file_code.expired_count < 0 |
| 623 | text_length = len(file_code.text) if file_code.text else 0 |
| 624 | can_download = is_text or bool(file_code.file_path or file_code.uuid_file_name) |
| 625 | status_insights = self._build_file_status_insights( |
| 626 | file_code=file_code, |
| 627 | detail=detail, |
| 628 | now=now, |
| 629 | has_download_limit=has_download_limit, |
| 630 | is_permanent=is_permanent, |
| 631 | can_download=can_download, |
| 632 | ) |
| 633 | timeline = self._build_file_timeline( |
| 634 | file_code=file_code, |
| 635 | detail=detail, |
| 636 | now=now, |
| 637 | has_download_limit=has_download_limit, |
| 638 | is_permanent=is_permanent, |
| 639 | is_text=is_text, |
| 640 | ) |
| 641 | |
| 642 | detail.update( |
| 643 | { |
| 644 | "filename": detail["name"], |
| 645 | "displayName": detail["name"], |
| 646 | "display_name": detail["name"], |
| 647 | "isPermanent": is_permanent, |
| 648 | "is_permanent": is_permanent, |
| 649 | "hasDownloadLimit": has_download_limit, |
| 650 | "has_download_limit": has_download_limit, |
| 651 | "hasExpirationTime": file_code.expired_at is not None, |
| 652 | "has_expiration_time": file_code.expired_at is not None, |
| 653 | "textLength": text_length, |
| 654 | "text_length": text_length, |
| 655 | "canPreviewText": is_text, |
| 656 | "can_preview_text": is_text, |
| 657 | "canDownload": can_download, |
| 658 | "can_download": can_download, |
| 659 | "storageBackend": settings.file_storage, |
| 660 | "storage_backend": settings.file_storage, |
| 661 | "filePath": file_code.file_path, |
| 662 | "file_path": file_code.file_path, |
| 663 | "uuidFileName": file_code.uuid_file_name, |
| 664 | "uuid_file_name": file_code.uuid_file_name, |
| 665 | "uploadId": file_code.upload_id, |
| 666 | "upload_id": file_code.upload_id, |
| 667 | "policy": { |
| 668 | "expiredAt": file_code.expired_at, |
| 669 | "expired_at": file_code.expired_at, |
| 670 | "expiredCount": file_code.expired_count, |
no test coverage detected