Fix processing/uploading status not showing after upload #193, updated comment in string_constants.tmpl

This commit is contained in:
Marc Ole Bulling
2024-07-22 20:12:58 +02:00
parent 38d5275e9e
commit 4f71a2b1c3
7 changed files with 11 additions and 16 deletions

View File

@@ -10,7 +10,7 @@ import (
"strings"
)
const versionJsAdmin = "4"
const versionJsAdmin = "5"
const versionJsDropzone = "4"
const versionJsE2EAdmin = "3"
const versionCssMain = "2"
@@ -76,7 +76,7 @@ func parseGokapiVersion() string {
return ""
}
const templateVersions = `// Change these for rebranding
const templateVersions = `// File contains auto-generated values. Do not change manually
{{define "version"}}%gokapiversion%{{end}}
// Specifies the version of JS files, so that the browser doesn't

View File

@@ -33,7 +33,7 @@ import (
// versionGokapi is the current version in readable form.
// Other version numbers can be modified in /build/go-generate/updateVersionNumbers.go
const versionGokapi = "1.9.0"
const versionGokapi = "1.9.1"
// The following calls update the version numbers, update documentation, minify Js/CSS and build the WASM modules
//go:generate go run "../../build/go-generate/updateVersionNumbers.go"

View File

@@ -12,13 +12,10 @@ type UploadStatus struct {
// hashing) or being moved/uploaded to the file storage
// See processingstatus for definition
CurrentStatus int `json:"currentstatus"`
// Type is the type of the message and is always "uploadstatus"
Type string `json:"type"`
}
// ToJson returns the struct as a Json byte array
func (u *UploadStatus) ToJson() ([]byte, error) {
u.Type = "uploadstatus"
return json.Marshal(u)
}

View File

@@ -16,7 +16,7 @@ const StatusUploading = 1
func passNewStatus(newStatus models.UploadStatus) {
status, err := newStatus.ToJson()
helper.Check(err)
sse.PublishNewStatus(string(status) + "\n")
sse.PublishNewStatus(string(status))
}
// Set sets the status for an id

View File

@@ -35,7 +35,7 @@ func removeListener(id string) {
func PublishNewStatus(reply string) {
mutex.RLock()
for _, channel := range listeners {
go channel.Reply(reply)
go channel.Reply("event: message\ndata: " + reply + "\n\n")
}
mutex.RUnlock()
}
@@ -71,7 +71,7 @@ func GetStatusSSE(w http.ResponseWriter, r *http.Request) {
for _, status := range allStatus {
jsonOutput, err := status.ToJson()
helper.Check(err)
_, _ = io.WriteString(w, string(jsonOutput)+"\n")
_, _ = io.WriteString(w, "event: message\ndata: "+string(jsonOutput)+"\n\n")
}
w.(http.Flusher).Flush()
for {
@@ -84,7 +84,7 @@ func GetStatusSSE(w http.ResponseWriter, r *http.Request) {
case reply := <-replyChannel:
_, _ = io.WriteString(w, reply)
case <-time.After(pingInterval):
_, _ = io.WriteString(w, "{\"type\":\"ping\"}\n")
_, _ = io.WriteString(w, "event: ping\n\n")
case <-ctx.Done():
removeListener(channelId)
return

View File

@@ -458,7 +458,7 @@ function registerChangeHandler() {
source.onmessage = (event) => {
try {
let eventData = JSON.parse(event.data);
setProgressStatus(eventData.chunkid, eventData.currentstatus);
setProgressStatus(eventData.chunkid, eventData.currentstatus);
} catch (e) {
console.error("Failed to parse event data:", e);
}
@@ -469,8 +469,6 @@ function registerChangeHandler() {
if (error.target.readyState !== EventSource.CLOSED) {
source.close();
}
console.log("Reconnecting to SSE...");
// Attempt to reconnect after a delay
setTimeout(registerChangeHandler, 5000);

View File

@@ -1,9 +1,9 @@
// File contains auto-generated values. Do not change manually
{{define "version"}}1.9.0{{end}}
{{define "version"}}1.9.1{{end}}
// Specifies the version of JS files, so that the browser doesn't
// use a cached version, if the file has been updated
{{define "js_admin_version"}}4{{end}}
{{define "js_admin_version"}}5{{end}}
{{define "js_dropzone_version"}}4{{end}}
{{define "js_e2eversion"}}3{{end}}
{{define "css_main"}}2{{end}}
{{define "css_main"}}2{{end}}