[pve-devel] [PATCH manager] ui: storage: handle empty response in case of file upload error

Thomas Lamprecht t.lamprecht at proxmox.com
Tue May 7 16:20:12 CEST 2019


On 5/7/19 1:46 PM, Tim Marx wrote:
> Signed-off-by: Tim Marx <t.marx at proxmox.com>
> ---
>  www/manager6/storage/ContentView.js | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)

applied, with followup. I found a few strange things when testing this:

* if the backend is full we get initially a strange behavior of a progress
  bar jumping back a few times to 0 before getting an error
* the "error" handler could also produce a few better errors, e.g., if the
  file get (re)moved between selecting it and hitting "upload" or for above
  case

for the backend full case we could add an optional "size" param to the
upload API, with that we could look if actual that much space is
available and abort early if not with a sane error message. This is
no guarantee, but easy to do and catches some low hanging fruits.
In firefox we'd have at least the file.size value available.

> 
> diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
> index b7615b22..907521cb 100644
> --- a/www/manager6/storage/ContentView.js
> +++ b/www/manager6/storage/ContentView.js
> @@ -290,13 +290,18 @@ Ext.define('PVE.storage.Upload', {
>  			me.close();
>  		    } else {
>  			var msg = gettext('Error') + " " + xhr.status.toString() + ": " + Ext.htmlEncode(xhr.statusText);
> -			var result = Ext.decode(xhr.responseText);
> -			result.message = msg;
> -			var htmlStatus = Proxmox.Utils.extractRequestError(result, true);
> -			Ext.Msg.alert(gettext('Error'), htmlStatus, function(btn) {
> -			    me.close();
> -			});
> -
> +			if (xhr.responseText !== "") {
> +			    var result = Ext.decode(xhr.responseText);
> +			    result.message = msg;
> +			    var htmlStatus = Proxmox.Utils.extractRequestError(result, true);
> +			    Ext.Msg.alert(gettext('Error'), htmlStatus, function(btn) {
> +				me.close();
> +			    });
> +			} else {
> +			    Ext.Msg.alert(gettext('Error'), msg, function(btn) {
> +				me.close();
> +			    });
> +			}
>  		    }
>  		}, false);
>  
> 





More information about the pve-devel mailing list