From 2162e2c15d4d3215873639f9da2e866eb724c2ba Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 30 Jun 2020 13:11:22 +0200 Subject: [PATCH] src/api2/admin/datastore.rs: avoid slash in UPID strings --- src/api2/admin/datastore.rs | 4 ++-- www/Utils.js | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index dae045b1..65a7fabc 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -441,13 +441,13 @@ pub fn verify( match (backup_type, backup_id, backup_time) { (Some(backup_type), Some(backup_id), Some(backup_time)) => { + worker_id = format!("{}_{}_{}_{:08X}", store, backup_type, backup_id, backup_time); let dir = BackupDir::new(backup_type, backup_id, backup_time); - worker_id = format!("{}_{}", store, dir); backup_dir = Some(dir); } (Some(backup_type), Some(backup_id), None) => { + worker_id = format!("{}_{}_{}", store, backup_type, backup_id); let group = BackupGroup::new(backup_type, backup_id); - worker_id = format!("{}_{}", store, group); backup_group = Some(group); } (None, None, None) => { diff --git a/www/Utils.js b/www/Utils.js index 662b7ce2..bd585c96 100644 --- a/www/Utils.js +++ b/www/Utils.js @@ -33,23 +33,18 @@ Ext.define('PBS.Utils', { }, render_datastore_worker_id: function(id, what) { - const result = id.match(/^(\S+)_([^_\s]+)_([^_\s]+)$/); - if (result) { - let datastore = result[1], type = result[2], id = result[3]; - return `Datastore ${datastore} - ${what} ${type}/${id}`; - } - return `Datastore ${id} - ${what}`; - }, - - render_datastore_time_worker_id: function(id, what) { - const res = id.match(/^(\S+)_([^_\s]+)_([^_\s]+)_([^_\s]+)$/); + const res = id.match(/^(\S+?)_(\S+?)_(\S+?)(_(.+))?$/); if (res) { let datastore = res[1], type = res[2], id = res[3]; - let datetime = Ext.Date.parse(parseInt(res[4], 16), 'U'); - let utctime = PBS.Utils.render_datetime_utc(datetime); - return `Datastore ${datastore} - ${what} ${type}/${id}/${utctime}`; + if (res[4] !== undefined) { + let datetime = Ext.Date.parse(parseInt(res[5], 16), 'U'); + let utctime = PBS.Utils.render_datetime_utc(datetime); + return `Datastore ${datastore} ${what} ${type}/${id}/${utctime}`; + } else { + return `Datastore ${datastore} ${what} ${type}/${id}`; + } } - return what; + return `Datastore ${what} ${id}`; }, constructor: function() { @@ -70,7 +65,7 @@ Ext.define('PBS.Utils', { return PBS.Utils.render_datastore_worker_id(id, gettext('Backup')); }, reader: (type, id) => { - return PBS.Utils.render_datastore_time_worker_id(id, gettext('Read objects')); + return PBS.Utils.render_datastore_worker_id(id, gettext('Read objects')); }, }); }