[Kimchi-devel] [PATCH] [Kimchi] Fixed Storage Volume upload error message when switching tabs

sguimaraes943 at gmail.com sguimaraes943 at gmail.com
Tue Jun 7 19:44:57 UTC 2016


From: Samuel Guimarães <sguimaraes943 at gmail.com>

This commit fixes a bug that would occur if the user starts uploading a volume and switches to a different tab or select a different Storage Pool and starts a new upload while the previous task is still in progress. It would return an error message as "KCHPOOL0002E: Storage pool undefined does not exist" and stop the upload progress but the upload task would keep returning "running" until Wok server is finished.
This was happening because the global variabel kimchi.selectedSP was sent as an argument to the functions kimchi.createVolumeWithCapacity() and kimchi.uploadVolumeToSP().

The solution was creating a copy of the current kimchi.selectedSP value in each kimchi.sp_add_volume_main() function call.

Signed-off-by: Samuel Guimarães <sguimaraes943 at gmail.com>
---
 ui/js/src/kimchi.storagepool_add_volume_main.js | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ui/js/src/kimchi.storagepool_add_volume_main.js b/ui/js/src/kimchi.storagepool_add_volume_main.js
index e167a20..ebace9c 100644
--- a/ui/js/src/kimchi.storagepool_add_volume_main.js
+++ b/ui/js/src/kimchi.storagepool_add_volume_main.js
@@ -23,6 +23,7 @@ kimchi.sp_add_volume_main = function() {
     var remoteURLBox = $('#volume-remote-url');
     var localFileBox = $('#volume-input-file');
     var typeRadios = $('input.volume-type');
+    var selectedStoragePool = kimchi.selectedSP.slice(0); // Makes a copy of kimchi.selectedSP
 
     var isValidURL = function() {
         var url = $(remoteURLBox).val();
@@ -70,7 +71,7 @@ kimchi.sp_add_volume_main = function() {
         var volumeURL = remoteURLBox.val();
         var volumeName = volumeURL.split(/(\\|\/)/g).pop();
         kimchi.downloadVolumeToSP({
-            sp: kimchi.selectedSP,
+            sp: selectedStoragePool,
             url: volumeURL
         }, function(result) {
             wok.window.close();
@@ -85,7 +86,7 @@ kimchi.sp_add_volume_main = function() {
         var blobFile = $(localFileBox)[0].files[0];
 
         var createUploadVol = function() {
-            kimchi.createVolumeWithCapacity(kimchi.selectedSP, {
+            kimchi.createVolumeWithCapacity(selectedStoragePool, {
                 name: blobFile.name,
                 format: '',
                 capacity: blobFile.size,
@@ -101,7 +102,7 @@ kimchi.sp_add_volume_main = function() {
             fd.append('chunk', blob);
             fd.append('chunk_size', blob.size);
 
-            kimchi.uploadVolumeToSP(kimchi.selectedSP, blobFile.name, {
+            kimchi.uploadVolumeToSP(selectedStoragePool, blobFile.name, {
                 formData: fd
             }, function(result) {
                 if (uploaded < blobFile.size){
-- 
1.9.3




More information about the Kimchi-devel mailing list