admin_kick_user. Admin-only route handler. This docstring was expanded to make future maintenance easier. Returns: Varies.
()
| 12216 | if any(ch in name for ch in ("/", "\\", "\x00", "\n", "\r")): |
| 12217 | raise ValueError("bad_name") |
| 12218 | return name |
| 12219 | |
| 12220 | |
| 12221 | def _unique_destination(directory: str, filename: str) -> str: |
| 12222 | candidate = os.path.join(directory, filename) |
| 12223 | if not os.path.exists(candidate): |
| 12224 | return candidate |
| 12225 | p = pathlib.Path(filename) |
| 12226 | stem, suffix = p.stem or p.name, p.suffix |
| 12227 | idx = 2 |
| 12228 | while True: |
| 12229 | candidate = os.path.join(directory, f"{stem} ({idx}){suffix}") |
| 12230 | if not os.path.exists(candidate): |
| 12231 | return candidate |
| 12232 | idx += 1 |
| 12233 | |
| 12234 | |
| 12235 | def _disk_allows_upload(target_dir: str, expected_total: int, already_written: int = 0) -> bool: |
| 12236 | try: |
| 12237 | usage = shutil.disk_usage(target_dir) |
| 12238 | remaining = max(0, int(expected_total) - max(0, int(already_written))) |
| 12239 | predicted = int(usage.used) + remaining |
| 12240 | return usage.total > 0 and (predicted / usage.total) < FILE_STORAGE_MAX_RATIO and usage.free >= remaining |
| 12241 | except Exception: |
| 12242 | return False |
| 12243 | |
| 12244 |
nothing calls this directly
no test coverage detected