public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager v3 1/3] api: factor out read_pwt_version and pwt_base_dir
Date: Thu, 19 Nov 2026 18:09:07 +0100	[thread overview]
Message-ID: <20261119171151.475428-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261119171151.475428-1-d.csapak@proxmox.com>

Getting the pwt version will be useful in other places later, so factor
it out into API2Tools.

While at it, change it to use 'PVE::File' and handle missing pwt file by
providing the default '' (to avoid a perl warning in that case).

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/API2Tools.pm        | 14 ++++++++++++++
 PVE/Service/pveproxy.pm |  6 +++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/PVE/API2Tools.pm b/PVE/API2Tools.pm
index bca21aa5..c53ec03f 100644
--- a/PVE/API2Tools.pm
+++ b/PVE/API2Tools.pm
@@ -12,6 +12,7 @@ use URI;
 use PVE::Cluster;
 use PVE::DataCenterConfig; # so we can cfs-read datacenter.cfg
 use PVE::Exception qw(raise_param_exc);
+use PVE::File;
 use PVE::INotify;
 use PVE::RPCEnvironment;
 use PVE::SafeSyslog;
@@ -272,4 +273,17 @@ sub get_resource_pool_guest_members {
     return $pool_members;
 }
 
+my $PWT_BASE_DIR = '/usr/share/javascript/proxmox-widget-toolkit';
+my $PWT_FILE = "$PWT_BASE_DIR/proxmoxlib.js";
+
+sub pwt_base_dir {
+    return $PWT_BASE_DIR;
+}
+
+sub read_pwt_version {
+    my $wtversionraw = PVE::File::file_read_first_line($PWT_FILE) // '';
+    my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : '';
+    return $wtversion;
+}
+
 1;
diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index acd23416..dc97f815 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -11,6 +11,7 @@ use URI::QueryParam;
 use URI;
 
 use PVE::API2;
+use PVE::API2Tools;
 use PVE::APIServer::AnyEvent;
 use PVE::APIServer::Formatter::HTML;
 use PVE::APIServer::Formatter::Standard;
@@ -56,7 +57,7 @@ my $basedirs = {
     novnc => '/usr/share/novnc-pve',
     yew_mobile => '/usr/share/pve-yew-mobile-gui',
     i18n_yew => '/usr/share/pve-yew-mobile-i18n',
-    widgettoolkit => '/usr/share/javascript/proxmox-widget-toolkit',
+    widgettoolkit => PVE::API2Tools::pwt_base_dir(),
     xtermjs => '/usr/share/pve-xtermjs',
 };
 
@@ -261,8 +262,7 @@ sub get_index {
 
     my $version = PVE::pvecfg::version();
 
-    my $wtversionraw = PVE::Tools::file_read_firstline("$basedirs->{widgettoolkit}/proxmoxlib.js");
-    my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : '';
+    my $wtversion = PVE::API2Tools::read_pwt_version();
 
     # while we could use the actual pkg version (e.g., shipped as pkg-version file in each
     # respective package's /usr/share/<pkg> folder, this way it should also work when using make
-- 
2.47.3





  reply	other threads:[~2026-11-19 17:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:09 [PATCH pve-manager v3 0/3] ui: prompt users for reload when web ui version changes Dominik Csapak
2026-11-19 17:09 ` Dominik Csapak [this message]
2026-11-19 17:09 ` [PATCH pve-manager v3 2/3] api: provide GUI versions via index and /cluster/resources Dominik Csapak
2026-11-19 17:09 ` [PATCH pve-manager v3 3/3] ui: workspace: prompt user for reload when UI packages were updated Dominik Csapak
2026-11-19 22:21 ` [PATCH pve-manager v3 0/3] ui: prompt users for reload when web ui version changes Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119171151.475428-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal