From 61aef41bee01a019b1e295c7c002742fe97e0a5f Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Wed, 22 Jan 2025 19:41:31 +0100 Subject: [PATCH] WebClient: make the keep alive interval configurable Signed-off-by: Nicola Murino --- internal/httpd/webclient.go | 3 +++ templates/webclient/files.html | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/httpd/webclient.go b/internal/httpd/webclient.go index e1363695..b66b7c54 100644 --- a/internal/httpd/webclient.go +++ b/internal/httpd/webclient.go @@ -145,6 +145,7 @@ type filesPage struct { Error *util.I18nError Paths []dirMapping QuotaUsage *userQuotaUsage + KeepAliveInterval int } type shareLoginPage struct { @@ -781,6 +782,7 @@ func (s *httpdServer) renderSharedFilesPage(w http.ResponseWriter, r *http.Reque CanCopy: false, Paths: getDirMapping(dirName, currentURL), QuotaUsage: newUserQuotaUsage(&dataprovider.User{}), + KeepAliveInterval: int(cookieRefreshThreshold / time.Millisecond), } renderClientTemplate(w, templateClientFiles, data) } @@ -837,6 +839,7 @@ func (s *httpdServer) renderFilesPage(w http.ResponseWriter, r *http.Request, di ShareUploadBaseURL: "", Paths: getDirMapping(dirName, webClientFilesPath), QuotaUsage: newUserQuotaUsage(user), + KeepAliveInterval: int(cookieRefreshThreshold / time.Millisecond), } renderClientTemplate(w, templateClientFiles, data) } diff --git a/templates/webclient/files.html b/templates/webclient/files.html index 6a00dcc7..dcd058d1 100644 --- a/templates/webclient/files.html +++ b/templates/webclient/files.html @@ -263,6 +263,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). "mscgen", "mscin", "msc", "xu", "msgenny", "wat", "wast", "env"]; const supportedEditFilenames = ["readme", "dockerfile", "pkgbuild"]; //{{- end}} + const keepAliveInterval = '{{.KeepAliveInterval}}'; function keepAlive() { //{{- if not .ShareUploadBaseURL}} axios.get('{{.PingURL}}',{ @@ -1974,7 +1975,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). function uploadFiles(files) { keepAlive(); - let keepAliveTimer = setInterval(keepAlive, 300000); + let keepAliveTimer = setInterval(keepAlive, keepAliveInterval); let has_errors = false; let index = 0; @@ -2189,7 +2190,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $("#video_player").get(0).load(); $('#modal_video_player').modal('show'); keepAlive(); - playerKeepAlive = setInterval(keepAlive, 300000); + playerKeepAlive = setInterval(keepAlive, keepAliveInterval); } $(document).on("i18nshow", function(){