diff --git a/.github/workflows/build_web.yml b/.github/workflows/build_web.yml index c70adeda0..5b10d7823 100644 --- a/.github/workflows/build_web.yml +++ b/.github/workflows/build_web.yml @@ -39,7 +39,7 @@ jobs: - name: 🛠️ Build using docker run: | - docker buildx build . -f dist/web/Dockerfile --progress=plain --build-arg 'JOBS=4' --output out + docker buildx build . -f dist/web/Dockerfile --progress=plain --build-arg 'JOBS=4' --output out --target raw - name: 🔨 Fix permissions run: | diff --git a/dist/web/Dockerfile b/dist/web/Dockerfile index 3b18de41b..aa25c96c1 100644 --- a/dist/web/Dockerfile +++ b/dist/web/Dockerfile @@ -73,7 +73,7 @@ cp /imhex/dist/web/source/* /build ccache -s EOF -FROM scratch +FROM scratch as raw COPY --from=build [ \ # ImHex \ "/build/imhex.wasm", \ @@ -93,4 +93,7 @@ COPY --from=build [ \ \ # Destination \ "./" \ -] \ No newline at end of file +] + +FROM nginx +COPY --from=raw . /usr/share/nginx/html diff --git a/dist/web/compose.yml b/dist/web/compose.yml new file mode 100644 index 000000000..9dad70e67 --- /dev/null +++ b/dist/web/compose.yml @@ -0,0 +1,10 @@ +# docker compose -f dist/web/compose.yml --build up +version: '3' +services: + imhex_web: + image: imhex_web:latest + build: + context: ../../ # ImHex folder + dockerfile: ./dist/web/Dockerfile + ports: + - 8080:80 diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index ee64cde8a..3e0265fa6 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -153,12 +153,14 @@ namespace hex::fs { for (let file of selector.files) { const fr = new FileReader(); fr.onload = () => { - let path = "/openedFiles/"+file.name; - if (FS.analyzePath(path).exists) { - FS.unlink(path); + let folder = "/openedFiles/"+Math.random().toString(36).substring(2)+"/"; + FS.createPath("/", folder); + if (FS.analyzePath(folder+file.name).exists) { + console.log(`Error: ${folder+file.name} already exist`); + } else { + FS.createDataFile(folder, file.name, fr.result, true, true); + Module._fileBrowserCallback(stringToNewUTF8(folder+file.name)); } - FS.createDataFile("/openedFiles/", file.name, fr.result, true, true); - Module._fileBrowserCallback(stringToNewUTF8(path)); }; fr.readAsBinaryString(file);