Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,9 +39,13 @@ HF_REPO_TYPE = "dataset"
|
|
| 39 |
TOTAL_DIVISIONS = 25
|
| 40 |
VALID_DIVISIONS = set(range(1, TOTAL_DIVISIONS + 1))
|
| 41 |
|
| 42 |
-
# Local Temporary Storage (
|
| 43 |
-
TEMP_DIR =
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# ==================================================
|
| 47 |
# ADMIN AUTH
|
|
@@ -289,7 +293,7 @@ async def get_asset_urls(base_url: str, guids: list) -> dict:
|
|
| 289 |
return (await post_json("webasseturls", base_url, payload)).get("items", {})
|
| 290 |
|
| 291 |
async def download_to_temp(url: str, filename: str) -> str:
|
| 292 |
-
# Use the explicitly created
|
| 293 |
path = os.path.join(TEMP_DIR, filename)
|
| 294 |
|
| 295 |
# Remove if exists to ensure clean slate
|
|
|
|
| 39 |
TOTAL_DIVISIONS = 25
|
| 40 |
VALID_DIVISIONS = set(range(1, TOTAL_DIVISIONS + 1))
|
| 41 |
|
| 42 |
+
# Local Temporary Storage (Use system /tmp which is writable)
|
| 43 |
+
TEMP_DIR = "/tmp/fundata_downloads"
|
| 44 |
+
try:
|
| 45 |
+
os.makedirs(TEMP_DIR, exist_ok=True)
|
| 46 |
+
except OSError:
|
| 47 |
+
# Fallback to python's temp dir if /tmp/fundata_downloads fails
|
| 48 |
+
TEMP_DIR = tempfile.mkdtemp()
|
| 49 |
|
| 50 |
# ==================================================
|
| 51 |
# ADMIN AUTH
|
|
|
|
| 293 |
return (await post_json("webasseturls", base_url, payload)).get("items", {})
|
| 294 |
|
| 295 |
async def download_to_temp(url: str, filename: str) -> str:
|
| 296 |
+
# Use the explicitly created safe temp directory
|
| 297 |
path = os.path.join(TEMP_DIR, filename)
|
| 298 |
|
| 299 |
# Remove if exists to ensure clean slate
|