all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox-backup] fix #7562: api/ui: make tape formatting in changer more consistent
@ 2026-05-08  9:32 Dominik Csapak
  2026-05-26 12:32 ` applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2026-05-08  9:32 UTC (permalink / raw)
  To: pbs-devel

the 'format-media' api call takes a 'label-text' which is used for two
things simultaneously:
1. load a tape from a slot into the drive (where it's barcode is the
   given label-text)
2. check if the label on the tape is the one given

The web ui uses the fact nr. 1 as a feature to load + format in one
step, to reduce the necessary user actions, but this has a drawback:

if the user wants to load+format a tape this way that is either empty
or has unrelated data on it, we refuse to format it due to fact nr. 2.

To improve this, introduce a separate parameter for loading a tape with
a given barcode, and using the label-text separately for checking the on
tape label.

This can be used in the ui to handle all use cases:
* load + format a labeled tape
* load + format an empty tape
* load + format a tape with unrelated data
* check label + format without loading from a slot
* force format without any checking

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---

I guess this could be seen as a breaking change, as we now require a new
parameter for loading the tape into the drive, but I currently don't see
a good way to keep this behavior while also fixing the bug properly.
(Without having a flag that uses the new behavior, that would still be
broken for the old one...)

 src/api2/tape/drive.rs    | 11 ++++++++---
 www/tape/ChangerStatus.js | 12 ++++++++++--
 www/tape/TapeInventory.js |  5 +++--
 www/tape/window/Erase.js  | 14 ++++++++++++--
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs
index 1a45ae406..c981fbb94 100644
--- a/src/api2/tape/drive.rs
+++ b/src/api2/tape/drive.rs
@@ -269,6 +269,10 @@ pub fn unload(
                 optional: true,
                 default: true,
             },
+            "load-barcode": {
+                schema: MEDIA_LABEL_SCHEMA,
+                optional: true,
+            },
             "label-text": {
                 schema: MEDIA_LABEL_SCHEMA,
                 optional: true,
@@ -286,6 +290,7 @@ pub fn unload(
 pub fn format_media(
     drive: String,
     fast: Option<bool>,
+    load_barcode: Option<String>,
     label_text: Option<String>,
     rpcenv: &mut dyn RpcEnvironment,
 ) -> Result<Value, Error> {
@@ -295,10 +300,10 @@ pub fn format_media(
         "format-media",
         Some(drive.clone()),
         move |_worker, config| {
-            if let Some(ref label) = label_text {
-                info!("try to load media '{label}'");
+            if let Some(barcode) = load_barcode {
+                info!("try to load media '{barcode}'");
                 if let Some((mut changer, _)) = media_changer(&config, &drive)? {
-                    changer.load_media(label)?;
+                    changer.load_media(&barcode)?;
                 }
             }
 
diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index e5d6d5d76..c979024a1 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -164,10 +164,17 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
         'format-inserted': function (button, event, record) {
             let me = this;
 
+            let params = {};
+            if (record.data['is-labeled']) {
+                params = {
+                    'label-text': record.data['label-text'],
+                };
+            }
             let view = me.getView();
             PBS.Utils.driveCommand(record.data.name, 'format-media', {
                 waitMsgTarget: view,
                 method: 'POST',
+                params,
                 success: function (response) {
                     Ext.create('Proxmox.window.TaskProgress', {
                         upid: response.result.data,
@@ -182,12 +189,13 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
         format: function (v, rI, cI, button, el, record) {
             let me = this;
             let view = me.getView();
-            let label = record.data['label-text'];
+            let barcode = record.data['label-text'];
 
             let changer = encodeURIComponent(view.changer);
             let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined;
             Ext.create('PBS.TapeManagement.EraseWindow', {
-                label,
+                barcode,
+                isLabeled: record.data['is-labeled'],
                 changer,
                 singleDrive,
                 listeners: {
diff --git a/www/tape/TapeInventory.js b/www/tape/TapeInventory.js
index 85e9fdea8..1e12a78e7 100644
--- a/www/tape/TapeInventory.js
+++ b/www/tape/TapeInventory.js
@@ -44,14 +44,15 @@ Ext.define('PBS.TapeManagement.TapeInventory', {
             if (!selection || selection.length < 1) {
                 return;
             }
-            let label = selection[0].data['label-text'];
+            let barcode = selection[0].data['label-text'];
             let inChanger = selection[0].data.location.startsWith('online-');
             let changer;
             if (inChanger) {
                 changer = selection[0].data.location.slice('online-'.length);
             }
             Ext.create('PBS.TapeManagement.EraseWindow', {
-                label,
+                barcode,
+                isLabeled: true,
                 changer,
                 listeners: {
                     destroy: function () {
diff --git a/www/tape/window/Erase.js b/www/tape/window/Erase.js
index 41df1a38f..e815f8e65 100644
--- a/www/tape/window/Erase.js
+++ b/www/tape/window/Erase.js
@@ -3,16 +3,18 @@ Ext.define('PBS.TapeManagement.EraseWindow', {
     mixins: ['Proxmox.Mixin.CBind'],
 
     changer: undefined,
-    label: undefined,
+    barcode: undefined,
+    isLabeled: false,
 
     cbindData: function (config) {
         let me = this;
         return {
+            label: me.isLabeled ? me.barcode : undefined,
             singleDrive: me.singleDrive,
             hasSingleDrive: !!me.singleDrive,
             warning: Ext.String.format(
                 gettext("Are you sure you want to format tape '{0}' ?"),
-                me.label,
+                me.barcode,
             ),
         };
     },
@@ -66,10 +68,18 @@ Ext.define('PBS.TapeManagement.EraseWindow', {
                                 hidden: '{changer}',
                             },
                         },
+                        {
+                            xtype: 'hidden',
+                            name: 'load-barcode',
+                            cbind: {
+                                value: '{barcode}',
+                            },
+                        },
                         {
                             xtype: 'hidden',
                             name: 'label-text',
                             cbind: {
+                                submitValue: '{isLabeled}',
                                 value: '{label}',
                             },
                         },
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* applied: [PATCH proxmox-backup] fix #7562: api/ui: make tape formatting in changer more consistent
  2026-05-08  9:32 [PATCH proxmox-backup] fix #7562: api/ui: make tape formatting in changer more consistent Dominik Csapak
@ 2026-05-26 12:32 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2026-05-26 12:32 UTC (permalink / raw)
  To: pbs-devel, Dominik Csapak

On Fri, 08 May 2026 11:32:06 +0200, Dominik Csapak wrote:
> the 'format-media' api call takes a 'label-text' which is used for two
> things simultaneously:
> 1. load a tape from a slot into the drive (where it's barcode is the
>    given label-text)
> 2. check if the label on the tape is the one given
> 
> The web ui uses the fact nr. 1 as a feature to load + format in one
> step, to reduce the necessary user actions, but this has a drawback:
> 
> [...]

Applied, thanks!

[1/1] fix #7562: api/ui: make tape formatting in changer more consistent
      commit: cf995492f8c867f09ef60c0590d0445daff1e5ae




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-26 12:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08  9:32 [PATCH proxmox-backup] fix #7562: api/ui: make tape formatting in changer more consistent Dominik Csapak
2026-05-26 12:32 ` applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal