Spaces:
Runtime error
Runtime error
Create temp/files.py
Browse files- bot/temp/files.py +16 -0
bot/temp/files.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PATH: bot/temp/files.py
|
| 2 |
+
import os
|
| 3 |
+
import uuid
|
| 4 |
+
from bot.core.settings import TMP_DIR
|
| 5 |
+
|
| 6 |
+
def make_temp_file_path(original_name: str) -> str:
|
| 7 |
+
safe = (original_name or "file.bin").replace("/", "_").replace("\\", "_")
|
| 8 |
+
uid = uuid.uuid4().hex[:10]
|
| 9 |
+
return os.path.join(TMP_DIR, "ytloader", f"{uid}_{safe}")
|
| 10 |
+
|
| 11 |
+
def cleanup_file(path: str) -> None:
|
| 12 |
+
try:
|
| 13 |
+
if path and os.path.exists(path):
|
| 14 |
+
os.remove(path)
|
| 15 |
+
except Exception:
|
| 16 |
+
pass
|