(style: str | None = None)
| 97 | |
| 98 | |
| 99 | async def get_random_code(style: str | None = None) -> str: |
| 100 | code_style = style or get_code_generate_type() |
| 101 | if code_style == "num": |
| 102 | code_style = "number" |
| 103 | if code_style == "string": |
| 104 | code_style = "secret" |
| 105 | |
| 106 | while True: |
| 107 | code = ( |
| 108 | await get_random_num() |
| 109 | if code_style == "number" |
| 110 | else await get_random_string() |
| 111 | ) |
| 112 | if not await FileCodes.filter(code=code).exists(): |
| 113 | return str(code) |
| 114 | |
| 115 | |
| 116 | async def calculate_file_hash(file: UploadFile, chunk_size=1024 * 1024) -> str: |
no test coverage detected