From f148d7fcf2a5dd40f76221c999921b0219e48683 Mon Sep 17 00:00:00 2001 From: sawka Date: Mon, 3 Jun 2024 13:22:44 -0700 Subject: [PATCH] change to /wave/file, update blockid to zoneid --- frontend/app/view/term.tsx | 10 +++++----- main.go | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/frontend/app/view/term.tsx b/frontend/app/view/term.tsx index c06cc0372..432822d85 100644 --- a/frontend/app/view/term.tsx +++ b/frontend/app/view/term.tsx @@ -114,19 +114,19 @@ const TerminalView = ({ blockId }: { blockId: string }) => { if (!termRef.current) { return; } - // load data from blockfile + // load data from filestore const startTs = Date.now(); let loadedBytes = 0; const localTerm = termRef.current; // avoids devmode double effect running issue (terminal gets created twice) const usp = new URLSearchParams(); - usp.set("blockid", blockId); + usp.set("zoneid", blockId); usp.set("name", "main"); - fetch("/wave/blockfile?" + usp.toString()) + fetch("/wave/file?" + usp.toString()) .then((resp) => { if (resp.ok) { return resp.arrayBuffer(); } - console.log("error loading blockfile", resp.status, resp.statusText); + console.log("error loading file", resp.status, resp.statusText); }) .then((data: ArrayBuffer) => { const uint8View = new Uint8Array(data); @@ -139,7 +139,7 @@ const TerminalView = ({ blockId }: { blockId: string }) => { }); initialLoadRef.current.loaded = true; initialLoadRef.current.heldData = []; - console.log(`terminal loaded blockfile ${loadedBytes} bytes, ${Date.now() - startTs}ms`); + console.log(`terminal loaded file ${loadedBytes} bytes, ${Date.now() - startTs}ms`); }); }, [termRef.current]); diff --git a/main.go b/main.go index a4be0f6e4..3a3eb07ac 100644 --- a/main.go +++ b/main.go @@ -72,7 +72,7 @@ func createWindow(windowData *wstore.Window, app *application.App) { Backdrop: application.MacBackdropTranslucent, TitleBar: application.MacTitleBarHiddenInset, }, - BackgroundColour: application.NewRGB(0, 0, 0), + BackgroundColour: application.NewRGBA(0, 0, 0, 255), URL: "/public/index.html?windowid=" + windowData.OID + "&clientid=" + client.OID, X: windowData.Pos.X, Y: windowData.Pos.Y, @@ -102,11 +102,11 @@ type waveAssetHandler struct { AssetHandler http.Handler } -func serveBlockFile(w http.ResponseWriter, r *http.Request) { - blockId := r.URL.Query().Get("blockid") +func serveWaveFile(w http.ResponseWriter, r *http.Request) { + zoneId := r.URL.Query().Get("zoneid") name := r.URL.Query().Get("name") - if _, err := uuid.Parse(blockId); err != nil { - http.Error(w, fmt.Sprintf("invalid blockid: %v", err), http.StatusBadRequest) + if _, err := uuid.Parse(zoneId); err != nil { + http.Error(w, fmt.Sprintf("invalid zoneid: %v", err), http.StatusBadRequest) return } if name == "" { @@ -114,7 +114,7 @@ func serveBlockFile(w http.ResponseWriter, r *http.Request) { return } - file, err := filestore.WFS.Stat(r.Context(), blockId, name) + file, err := filestore.WFS.Stat(r.Context(), zoneId, name) if err == fs.ErrNotExist { http.NotFound(w, r) return @@ -129,16 +129,16 @@ func serveBlockFile(w http.ResponseWriter, r *http.Request) { } w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Length", fmt.Sprintf("%d", file.Size)) - w.Header().Set("X-BlockFileInfo", base64.StdEncoding.EncodeToString(jsonFileBArr)) + w.Header().Set("X-ZoneFileInfo", base64.StdEncoding.EncodeToString(jsonFileBArr)) w.Header().Set("Last-Modified", time.UnixMilli(file.ModTs).UTC().Format(http.TimeFormat)) for offset := file.DataStartIdx(); offset < file.Size; offset += filestore.DefaultPartDataSize { - _, data, err := filestore.WFS.ReadAt(r.Context(), blockId, name, offset, filestore.DefaultPartDataSize) + _, data, err := filestore.WFS.ReadAt(r.Context(), zoneId, name, offset, filestore.DefaultPartDataSize) if err != nil { if offset == 0 { http.Error(w, fmt.Sprintf("error reading file: %v", err), http.StatusInternalServerError) } else { // nothing to do, the headers have already been sent - log.Printf("error reading file %s/%s @ %d: %v\n", blockId, name, offset, err) + log.Printf("error reading file %s/%s @ %d: %v\n", zoneId, name, offset, err) } return } @@ -154,8 +154,8 @@ func serveWaveUrls(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, fileName) return } - if r.URL.Path == "/wave/blockfile" { - serveBlockFile(w, r) + if r.URL.Path == "/wave/file" { + serveWaveFile(w, r) return } http.NotFound(w, r)