|
1 | 1 | import gzip
|
2 | 2 | import io
|
3 | 3 | import mimetypes
|
4 |
| -import os |
5 | 4 | import uuid
|
6 |
| -from os import path |
| 5 | +from os import path, walk |
7 | 6 | from typing import Generic, Optional, TypeVar
|
8 | 7 |
|
9 | 8 | import dagster._check as check
|
|
33 | 32 | StreamingResponse,
|
34 | 33 | )
|
35 | 34 | from starlette.routing import Mount, Route, WebSocketRoute
|
36 |
| -from starlette.staticfiles import StaticFiles |
37 | 35 | from starlette.types import Message
|
38 | 36 |
|
39 | 37 | from dagster_webserver.external_assets import (
|
@@ -260,24 +258,12 @@ def _static_file(path, file_path):
|
260 | 258 |
|
261 | 259 | routes = []
|
262 | 260 | base_dir = self.relative_path("webapp/build/")
|
263 |
| - with os.scandir(base_dir) as entries: |
264 |
| - for entry in entries: |
265 |
| - if entry.is_symlink(): |
266 |
| - continue |
267 |
| - relative_path = "/" + path.relpath(entry.path, base_dir).replace(path.sep, "/") |
268 |
| - if entry.is_file(): |
269 |
| - routes.append(_static_file(relative_path, entry.path)) |
270 |
| - elif entry.is_dir(): |
271 |
| - routes.append( |
272 |
| - Mount( |
273 |
| - relative_path, |
274 |
| - StaticFiles( |
275 |
| - directory=entry.path, |
276 |
| - check_dir=False, |
277 |
| - ), |
278 |
| - name="root_static", |
279 |
| - ) |
280 |
| - ) |
| 261 | + for subdir, _, files in walk(base_dir): |
| 262 | + for file in files: |
| 263 | + full_path = path.join(subdir, file) |
| 264 | + # Replace path.sep to make sure our routes use forward slashes on windows |
| 265 | + mount_path = "/" + full_path[len(base_dir) :].replace(path.sep, "/") |
| 266 | + routes.append(_static_file(mount_path, full_path)) |
281 | 267 |
|
282 | 268 | # No build directory, this happens in a test environment. Don't fail loudly since we already have other tests that will fail loudly if
|
283 | 269 | # there is in fact no build
|
|
0 commit comments