understanding commited on
Commit
806b771
·
verified ·
1 Parent(s): ae10e13

Create temp/files.py

Browse files
Files changed (1) hide show
  1. 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