|
17 | 17 |
|
18 | 18 | from .. import tira_model as model
|
19 | 19 | from ..authentication import auth
|
20 |
| -from ..checks import ( |
21 |
| - check_conditional_permissions, |
22 |
| - check_permissions, |
23 |
| - check_resources_exist, |
24 |
| -) |
| 20 | +from ..checks import check_conditional_permissions, check_permissions, check_resources_exist |
25 | 21 | from ..git_runner import check_that_git_integration_is_valid
|
26 | 22 | from ..ir_datasets_loader import run_irds_command
|
27 | 23 | from .v1._datasets import download_mirrored_resource
|
@@ -219,18 +215,19 @@ def admin_delete_task(request, task_id):
|
219 | 215 | def file_listing(path, title):
|
220 | 216 | path = Path(path)
|
221 | 217 | children = []
|
222 |
| - for f in os.listdir(path): |
223 |
| - if len(children) > 5: |
224 |
| - children += [{"title": "..."}] |
225 |
| - break |
226 |
| - |
227 |
| - if os.path.isdir(path / f): |
228 |
| - c = file_listing(path / f, str(f))["children"] |
229 |
| - children += [{"title": f, "children": c}] |
230 |
| - else: |
231 |
| - md5 = hashlib.md5(open(path / f, "rb").read()).hexdigest() |
232 |
| - size = os.path.getsize(path / f) |
233 |
| - children += [{"title": f + f" (size: {size}; md5sum: {md5})", "size": size, "md5sum": md5}] |
| 218 | + if path and Path(path).exists() and Path(path).is_dir(): |
| 219 | + for f in os.listdir(path): |
| 220 | + if len(children) > 5: |
| 221 | + children += [{"title": "..."}] |
| 222 | + break |
| 223 | + |
| 224 | + if os.path.isdir(path / f): |
| 225 | + c = file_listing(path / f, str(f))["children"] |
| 226 | + children += [{"title": f, "children": c}] |
| 227 | + else: |
| 228 | + md5 = hashlib.md5(open(path / f, "rb").read()).hexdigest() |
| 229 | + size = os.path.getsize(path / f) |
| 230 | + children += [{"title": f + f" (size: {size}; md5sum: {md5})", "size": size, "md5sum": md5}] |
234 | 231 |
|
235 | 232 | current_item = {"title": title}
|
236 | 233 | if len(children) > 0:
|
|
0 commit comments