update
Browse files
app.py
CHANGED
@@ -2234,14 +2234,23 @@ with gr.Blocks(
|
|
2234 |
# Duplicate the Svelte template space
|
2235 |
duplicated_repo = duplicate_space(
|
2236 |
from_id="static-templates/svelte",
|
2237 |
-
to_id=space_name
|
2238 |
token=token.token,
|
2239 |
exist_ok=True
|
2240 |
)
|
2241 |
print("Duplicated Svelte repo result:", duplicated_repo, type(duplicated_repo))
|
2242 |
# Extract the actual repo ID from the duplicated space
|
2243 |
-
|
2244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2245 |
print("Actual repo ID for Svelte uploads:", actual_repo_id)
|
2246 |
|
2247 |
# Parse the Svelte output to get the custom files
|
@@ -2264,11 +2273,11 @@ with gr.Blocks(
|
|
2264 |
path_in_repo="src/App.svelte",
|
2265 |
repo_id=actual_repo_id,
|
2266 |
repo_type="space"
|
2267 |
-
|
2268 |
except Exception as e:
|
2269 |
error_msg = str(e)
|
2270 |
if "403 Forbidden" in error_msg and "write token" in error_msg:
|
2271 |
-
return gr.update(value=f"Error: Permission denied. Please ensure you have write access to {
|
2272 |
else:
|
2273 |
return gr.update(value=f"Error uploading src/App.svelte: {e}", visible=True)
|
2274 |
finally:
|
@@ -2291,7 +2300,7 @@ with gr.Blocks(
|
|
2291 |
except Exception as e:
|
2292 |
error_msg = str(e)
|
2293 |
if "403 Forbidden" in error_msg and "write token" in error_msg:
|
2294 |
-
return gr.update(value=f"Error: Permission denied. Please ensure you have write access to {
|
2295 |
else:
|
2296 |
return gr.update(value=f"Error uploading src/app.css: {e}", visible=True)
|
2297 |
finally:
|
@@ -2314,7 +2323,7 @@ with gr.Blocks(
|
|
2314 |
except Exception as e:
|
2315 |
error_msg = str(e)
|
2316 |
if "403 Forbidden" in error_msg and "write token" in error_msg:
|
2317 |
-
return gr.update(value=f"Error: Permission denied. Please ensure you have write access to {
|
2318 |
else:
|
2319 |
return gr.update(value=f"Error uploading src/lib/Counter.svelte: {e}", visible=True)
|
2320 |
finally:
|
|
|
2234 |
# Duplicate the Svelte template space
|
2235 |
duplicated_repo = duplicate_space(
|
2236 |
from_id="static-templates/svelte",
|
2237 |
+
to_id=repo_id, # Use the full repo_id (username/space_name)
|
2238 |
token=token.token,
|
2239 |
exist_ok=True
|
2240 |
)
|
2241 |
print("Duplicated Svelte repo result:", duplicated_repo, type(duplicated_repo))
|
2242 |
# Extract the actual repo ID from the duplicated space
|
2243 |
+
# The duplicated_repo is a RepoUrl object, convert to string and extract the repo ID
|
2244 |
+
duplicated_repo_str = str(duplicated_repo)
|
2245 |
+
# Extract username and repo name from the URL
|
2246 |
+
if "/spaces/" in duplicated_repo_str:
|
2247 |
+
parts = duplicated_repo_str.split("/spaces/")[-1].split("/")
|
2248 |
+
if len(parts) >= 2:
|
2249 |
+
actual_repo_id = f"{parts[0]}/{parts[1]}"
|
2250 |
+
else:
|
2251 |
+
actual_repo_id = repo_id # Fallback to original
|
2252 |
+
else:
|
2253 |
+
actual_repo_id = repo_id # Fallback to original
|
2254 |
print("Actual repo ID for Svelte uploads:", actual_repo_id)
|
2255 |
|
2256 |
# Parse the Svelte output to get the custom files
|
|
|
2273 |
path_in_repo="src/App.svelte",
|
2274 |
repo_id=actual_repo_id,
|
2275 |
repo_type="space"
|
2276 |
+
)
|
2277 |
except Exception as e:
|
2278 |
error_msg = str(e)
|
2279 |
if "403 Forbidden" in error_msg and "write token" in error_msg:
|
2280 |
+
return gr.update(value=f"Error: Permission denied. Please ensure you have write access to {actual_repo_id} and your token has the correct permissions.", visible=True)
|
2281 |
else:
|
2282 |
return gr.update(value=f"Error uploading src/App.svelte: {e}", visible=True)
|
2283 |
finally:
|
|
|
2300 |
except Exception as e:
|
2301 |
error_msg = str(e)
|
2302 |
if "403 Forbidden" in error_msg and "write token" in error_msg:
|
2303 |
+
return gr.update(value=f"Error: Permission denied. Please ensure you have write access to {actual_repo_id} and your token has the correct permissions.", visible=True)
|
2304 |
else:
|
2305 |
return gr.update(value=f"Error uploading src/app.css: {e}", visible=True)
|
2306 |
finally:
|
|
|
2323 |
except Exception as e:
|
2324 |
error_msg = str(e)
|
2325 |
if "403 Forbidden" in error_msg and "write token" in error_msg:
|
2326 |
+
return gr.update(value=f"Error: Permission denied. Please ensure you have write access to {actual_repo_id} and your token has the correct permissions.", visible=True)
|
2327 |
else:
|
2328 |
return gr.update(value=f"Error uploading src/lib/Counter.svelte: {e}", visible=True)
|
2329 |
finally:
|