From db1aeb008f8f3612b4698b09dbaca179cbf22b5b Mon Sep 17 00:00:00 2001 From: Barath Kumar R Date: Tue, 13 Oct 2020 18:14:16 +0530 Subject: [PATCH] Bug 1253 Updating the VNFD via ngUI breaks charms execution * Fixed the bug by adding the symbolic link while extracting the file and while doing tar. * The file upload size is increased upto 50MB in UI Change-Id: Ib1de6129018f11ce863a12a60e2ffab04187e795 Signed-off-by: Barath Kumar R --- nginx/nginx.conf | 2 +- src/assets/i18n/de.json | 8 +- src/assets/i18n/en.json | 8 +- src/assets/i18n/es.json | 8 +- src/assets/i18n/pt.json | 8 +- src/assets/js/tar.js | 688 ++++++++++++++------------- src/environments/environment.prod.ts | 2 +- src/environments/environment.ts | 2 +- src/models/CommonModel.ts | 10 + src/services/SharedService.ts | 16 +- 10 files changed, 392 insertions(+), 360 deletions(-) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index d686603..1d3f29d 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -20,7 +20,7 @@ server { server_name localhost; root /usr/share/nginx/html; index index.html index.htm; - client_max_body_size 15M; + client_max_body_size 50M; location /osm { proxy_pass https://nbi:9999; diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 9e87be9..7724414 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -106,10 +106,10 @@ "SHOWGRAPH": "Grafik anzeigen", "UPDATESHOWGRAPH": "Grafik aktualisieren und anzeigen", "CREATEPACKAGE": "Neues Paket erstellen", - "GZFILETYPEERRROR": "Laden Sie nur eine tar.gz-Datei hoch und die Größe sollte 15 MB nicht überschreiten", - "YAMLFILETYPEERRROR": "Laden Sie nur YAML-Dateien hoch und die Größe sollte 15 MB nicht überschreiten", - "JSONFILETYPEERRROR": "Laden Sie nur JSON-Dateien hoch und die Größe sollte 15 MB nicht überschreiten", - "PUBFILETYPEERRROR": "Laden Sie nur PUB-Dateien hoch und die Größe sollte 15 MB nicht überschreiten", + "GZFILETYPEERRROR": "Laden Sie nur eine tar.gz-Datei hoch und die Größe sollte 50 MB nicht überschreiten", + "YAMLFILETYPEERRROR": "Laden Sie nur YAML-Dateien hoch und die Größe sollte 50 MB nicht überschreiten", + "JSONFILETYPEERRROR": "Laden Sie nur JSON-Dateien hoch und die Größe sollte 50 MB nicht überschreiten", + "PUBFILETYPEERRROR": "Laden Sie nur PUB-Dateien hoch und die Größe sollte 50 MB nicht überschreiten", "PACKAGE": "Paket", "URL": "URL", "DEPLOYED": "Bereitgestellt", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 688bfc8..9e0c5a0 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -106,10 +106,10 @@ "SHOWGRAPH": "Show Graph", "UPDATESHOWGRAPH": "Update and Show Graph", "CREATEPACKAGE": "Create New Package", - "GZFILETYPEERRROR": "Upload only tar.gz file and size should not exceed 15 MB", - "YAMLFILETYPEERRROR": "Upload only YAML file and size should not exceed 15 MB", - "JSONFILETYPEERRROR": "Upload only JSON file and size should not exceed 15 MB", - "PUBFILETYPEERRROR": "Upload only PUB file and size should not exceed 15 MB", + "GZFILETYPEERRROR": "Upload only tar.gz file and size should not exceed 50 MB", + "YAMLFILETYPEERRROR": "Upload only YAML file and size should not exceed 50 MB", + "JSONFILETYPEERRROR": "Upload only JSON file and size should not exceed 50 MB", + "PUBFILETYPEERRROR": "Upload only PUB file and size should not exceed 50 MB", "PACKAGE": "Package", "URL": "URL", "DEPLOYED": "Deployed", diff --git a/src/assets/i18n/es.json b/src/assets/i18n/es.json index cf7c1fa..dd9d08b 100644 --- a/src/assets/i18n/es.json +++ b/src/assets/i18n/es.json @@ -106,10 +106,10 @@ "SHOWGRAPH": "Mostrar gráfico", "UPDATESHOWGRAPH": "Actualizar y mostrar gráfico", "CREATEPACKAGE": "Crear nuevo paquete", - "GZFILETYPEERRROR": "Cargue solo el archivo tar.gz, el tamaño no debe exceder los 15 MB", - "YAMLFILETYPEERRROR": "Cargue solo el archivo YAML, el tamaño no debe exceder los 15 MB", - "JSONFILETYPEERRROR": "Cargue solo el archivo JSON, el tamaño no debe exceder los 15 MB", - "PUBFILETYPEERRROR": "Cargue solo el archivo PUB, el tamaño no debe exceder los 15 MB", + "GZFILETYPEERRROR": "Cargue solo el archivo tar.gz, el tamaño no debe exceder los 50 MB", + "YAMLFILETYPEERRROR": "Cargue solo el archivo YAML, el tamaño no debe exceder los 50 MB", + "JSONFILETYPEERRROR": "Cargue solo el archivo JSON, el tamaño no debe exceder los 50 MB", + "PUBFILETYPEERRROR": "Cargue solo el archivo PUB, el tamaño no debe exceder los 50 MB", "PACKAGE": "Paquete", "URL": "URL", "DEPLOYED": "Desplegada", diff --git a/src/assets/i18n/pt.json b/src/assets/i18n/pt.json index 16476dc..48a9fbe 100644 --- a/src/assets/i18n/pt.json +++ b/src/assets/i18n/pt.json @@ -106,10 +106,10 @@ "SHOWGRAPH": "Mostrar gráfico", "UPDATESHOWGRAPH": "Atualizar e mostrar gráfico", "CREATEPACKAGE": "Criar novo pacote", - "GZFILETYPEERRROR": "Carregue apenas o arquivo tar.gz e o tamanho não deve exceder 15 MB", - "YAMLFILETYPEERRROR": "Carregar apenas arquivo YAML e o tamanho não deve exceder 15 MB", - "JSONFILETYPEERRROR": "Carregar apenas arquivo JSON e o tamanho não deve exceder 15 MB", - "PUBFILETYPEERRROR": "Carregar apenas arquivo PUB e o tamanho não deve exceder 15 MB", + "GZFILETYPEERRROR": "Carregue apenas o arquivo tar.gz e o tamanho não deve exceder 50 MB", + "YAMLFILETYPEERRROR": "Carregar apenas arquivo YAML e o tamanho não deve exceder 50 MB", + "JSONFILETYPEERRROR": "Carregar apenas arquivo JSON e o tamanho não deve exceder 50 MB", + "PUBFILETYPEERRROR": "Carregar apenas arquivo PUB e o tamanho não deve exceder 50 MB", "PACKAGE": "Pacote", "URL": "URL", "DEPLOYED": "Deployed", diff --git a/src/assets/js/tar.js b/src/assets/js/tar.js index 058d1ee..64d25c3 100644 --- a/src/assets/js/tar.js +++ b/src/assets/js/tar.js @@ -16,7 +16,7 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in) */ var Tar = -/******/ (function(modules) { // webpackBootstrap +/******/ (function (modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ @@ -24,15 +24,17 @@ var Tar = /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { +/******/ if (installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; -/******/ } + /******/ +} /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} -/******/ }; + /******/ +}; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); @@ -42,7 +44,8 @@ var Tar = /******/ /******/ // Return the exports of the module /******/ return module.exports; -/******/ } + /******/ +} /******/ /******/ /******/ // expose the modules object (__webpack_modules__) @@ -52,381 +55,390 @@ var Tar = /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context -/******/ __webpack_require__.i = function(value) { return value; }; +/******/ __webpack_require__.i = function (value) { return value; }; /******/ /******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { +/******/ __webpack_require__.d = function (exports, name, getter) { +/******/ if (!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter -/******/ }); -/******/ } -/******/ }; + /******/ +}); + /******/ +} + /******/ +}; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { +/******/ __webpack_require__.n = function (module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; -/******/ }; + /******/ +}; /******/ /******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ __webpack_require__.o = function (object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 2); -/******/ }) + /******/ +}) /************************************************************************/ -/******/ ([ +/******/([ /* 0 */ -/***/ (function(module, exports) { - -/* - * tar-js - * MIT (c) 2011 T. Jameson Little - */ +/***/ (function (module, exports) { + + /* + * tar-js + * MIT (c) 2011 T. Jameson Little + */ + + (function () { + "use strict"; + + var lookup = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' + ]; + function clean(length) { + var i, buffer = new Uint8Array(length); + for (i = 0; i < length; i += 1) { + buffer[i] = 0; + } + return buffer; + } -(function () { - "use strict"; - - var lookup = [ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9', '+', '/' - ]; - function clean(length) { - var i, buffer = new Uint8Array(length); - for (i = 0; i < length; i += 1) { - buffer[i] = 0; - } - return buffer; - } - - function extend(orig, length, addLength, multipleOf) { - var newSize = length + addLength, - buffer = clean((parseInt(newSize / multipleOf) + 1) * multipleOf); - - buffer.set(orig); - - return buffer; - } - - function pad(num, bytes, base) { - num = num.toString(base || 8); - return "000000000000".substr(num.length + 12 - bytes) + num; - } - - function stringToUint8 (input, out, offset) { - var i, length; - - out = out || clean(input.length); - - offset = offset || 0; - for (i = 0, length = input.length; i < length; i += 1) { - out[offset] = input.charCodeAt(i); - offset += 1; - } - - return out; - } - - function uint8ToBase64(uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length; - - function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; - }; - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); - output += tripletToBase64(temp); - } - - // this prevents an ERR_INVALID_URL in Chrome (Firefox okay) - switch (output.length % 4) { - case 1: - output += '='; - break; - case 2: - output += '=='; - break; - default: - break; - } - - return output; - } - - module.exports.clean = clean; - module.exports.pad = pad; - module.exports.extend = extend; - module.exports.stringToUint8 = stringToUint8; - module.exports.uint8ToBase64 = uint8ToBase64; -}()); - - -/***/ }), -/* 1 */ -/***/ (function(module, exports, __webpack_require__) { + function extend(orig, length, addLength, multipleOf) { + var newSize = length + addLength, + buffer = clean((parseInt(newSize / multipleOf) + 1) * multipleOf); -/* - * tar-js - * MIT (c) 2011 T. Jameson Little - */ + buffer.set(orig); -(function () { - "use strict"; - -/* -struct posix_header { // byte offset - char name[100]; // 0 - char mode[8]; // 100 - char uid[8]; // 108 - char gid[8]; // 116 - char size[12]; // 124 - char mtime[12]; // 136 - char chksum[8]; // 148 - char typeflag; // 156 - char linkname[100]; // 157 - char magic[6]; // 257 - char version[2]; // 263 - char uname[32]; // 265 - char gname[32]; // 297 - char devmajor[8]; // 329 - char devminor[8]; // 337 - char prefix[155]; // 345 - // 500 -}; -*/ - - var utils = __webpack_require__(0), - headerFormat; - - headerFormat = [ - { - 'field': 'fileName', - 'length': 100 - }, - { - 'field': 'fileMode', - 'length': 8 - }, - { - 'field': 'uid', - 'length': 8 - }, - { - 'field': 'gid', - 'length': 8 - }, - { - 'field': 'fileSize', - 'length': 12 - }, - { - 'field': 'mtime', - 'length': 12 - }, - { - 'field': 'checksum', - 'length': 8 - }, - { - 'field': 'type', - 'length': 1 - }, - { - 'field': 'linkName', - 'length': 100 - }, - { - 'field': 'ustar', - 'length': 8 - }, - { - 'field': 'owner', - 'length': 32 - }, - { - 'field': 'group', - 'length': 32 - }, - { - 'field': 'majorNumber', - 'length': 8 - }, - { - 'field': 'minorNumber', - 'length': 8 - }, - { - 'field': 'filenamePrefix', - 'length': 155 - }, - { - 'field': 'padding', - 'length': 12 - } - ]; - - function formatHeader(data, cb) { - var buffer = utils.clean(512), - offset = 0; - - headerFormat.forEach(function (value) { - var str = data[value.field] || "", - i, length; - - for (i = 0, length = str.length; i < length; i += 1) { - buffer[offset] = str.charCodeAt(i); - offset += 1; + return buffer; } - offset += value.length - i; // space it out with nulls - }); - - if (typeof cb === 'function') { - return cb(buffer, offset); - } - return buffer; - } - - module.exports.structure = headerFormat; - module.exports.format = formatHeader; -}()); + function pad(num, bytes, base) { + num = num.toString(base || 8); + return "000000000000".substr(num.length + 12 - bytes) + num; + } + function stringToUint8(input, out, offset) { + var i, length; -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { + out = out || clean(input.length); -/* - * tar-js - * MIT (c) 2011 T. Jameson Little - */ + offset = offset || 0; + for (i = 0, length = input.length; i < length; i += 1) { + out[offset] = input.charCodeAt(i); + offset += 1; + } -(function () { - "use strict"; - - var header = __webpack_require__(1), - utils = __webpack_require__(0), - recordSize = 512, - blockSize; - - function Tar(recordsPerBlock) { - this.written = 0; - blockSize = (recordsPerBlock || 20) * recordSize; - this.out = utils.clean(blockSize); - } - - Tar.prototype.append = function (filepath, input, opts, callback) { - var data, - checksum, - mode, - mtime, - uid, - gid, - headerArr; - - if (typeof input === 'string') { - input = utils.stringToUint8(input); - } else if (input.constructor !== Uint8Array.prototype.constructor) { - throw 'Invalid input type. You gave me: ' + input.constructor.toString().match(/function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/)[1]; - } - - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - - opts = opts || {}; - - mode = opts.mode || parseInt('777', 8) & 0xfff; - mtime = opts.mtime || Math.floor(+new Date() / 1000); - uid = opts.uid || 0; - gid = opts.gid || 0; - - data = { - fileName: filepath, - fileMode: utils.pad(mode, 7), - uid: utils.pad(uid, 7), - gid: utils.pad(gid, 7), - fileSize: utils.pad(input.length, 11), - mtime: utils.pad(mtime, 11), - checksum: ' ', - type: opts.type || '0', - ustar: 'ustar ', - owner: opts.owner || '', - group: opts.group || '' - }; - - // calculate the checksum - checksum = 0; - Object.keys(data).forEach(function (key) { - var i, value = data[key], length; - - for (i = 0, length = value.length; i < length; i += 1) { - checksum += value.charCodeAt(i); + return out; } - }); - - data.checksum = utils.pad(checksum, 6) + "\u0000 "; - headerArr = header.format(data); - - var i, offset, length; + function uint8ToBase64(uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length; + + function tripletToBase64(num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; + }; + + // go through the array every three bytes, we'll deal with trailing stuff later + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); + output += tripletToBase64(temp); + } + + // this prevents an ERR_INVALID_URL in Chrome (Firefox okay) + switch (output.length % 4) { + case 1: + output += '='; + break; + case 2: + output += '=='; + break; + default: + break; + } + + return output; + } - this.out.set(headerArr, this.written); + module.exports.clean = clean; + module.exports.pad = pad; + module.exports.extend = extend; + module.exports.stringToUint8 = stringToUint8; + module.exports.uint8ToBase64 = uint8ToBase64; + }()); - this.written += headerArr.length; - // If there is not enough space in this.out, we need to expand it to - // fit the new input. - if (this.written + input.length > this.out.length) { - this.out = utils.extend(this.out, this.written, input.length, blockSize); - } + /***/ +}), +/* 1 */ +/***/ (function (module, exports, __webpack_require__) { + + /* + * tar-js + * MIT (c) 2011 T. Jameson Little + */ + + (function () { + "use strict"; + + /* + struct posix_header { // byte offset + char name[100]; // 0 + char mode[8]; // 100 + char uid[8]; // 108 + char gid[8]; // 116 + char size[12]; // 124 + char mtime[12]; // 136 + char chksum[8]; // 148 + char typeflag; // 156 + char linkname[100]; // 157 + char magic[6]; // 257 + char version[2]; // 263 + char uname[32]; // 265 + char gname[32]; // 297 + char devmajor[8]; // 329 + char devminor[8]; // 337 + char prefix[155]; // 345 + // 500 + }; + */ + + var utils = __webpack_require__(0), + headerFormat; + + headerFormat = [ + { + 'field': 'fileName', + 'length': 100 + }, + { + 'field': 'fileMode', + 'length': 8 + }, + { + 'field': 'uid', + 'length': 8 + }, + { + 'field': 'gid', + 'length': 8 + }, + { + 'field': 'fileSize', + 'length': 12 + }, + { + 'field': 'mtime', + 'length': 12 + }, + { + 'field': 'checksum', + 'length': 8 + }, + { + 'field': 'type', + 'length': 1 + }, + { + 'field': 'linkName', + 'length': 100 + }, + { + 'field': 'ustar', + 'length': 8 + }, + { + 'field': 'owner', + 'length': 32 + }, + { + 'field': 'group', + 'length': 32 + }, + { + 'field': 'majorNumber', + 'length': 8 + }, + { + 'field': 'minorNumber', + 'length': 8 + }, + { + 'field': 'filenamePrefix', + 'length': 155 + }, + { + 'field': 'padding', + 'length': 12 + } + ]; + + function formatHeader(data, cb) { + var buffer = utils.clean(512), + offset = 0; + + headerFormat.forEach(function (value) { + var str = data[value.field] || "", + i, length; + + for (i = 0, length = str.length; i < length; i += 1) { + buffer[offset] = str.charCodeAt(i); + offset += 1; + } + + offset += value.length - i; // space it out with nulls + }); + + if (typeof cb === 'function') { + return cb(buffer, offset); + } + return buffer; + } - this.out.set(input, this.written); + module.exports.structure = headerFormat; + module.exports.format = formatHeader; + }()); - // to the nearest multiple of recordSize - this.written += input.length + (recordSize - (input.length % recordSize || recordSize)); - // make sure there's at least 2 empty records worth of extra space - if (this.out.length - this.written < recordSize * 2) { - this.out = utils.extend(this.out, this.written, recordSize * 2, blockSize); - } + /***/ +}), +/* 2 */ +/***/ (function (module, exports, __webpack_require__) { - if (typeof callback === 'function') { - callback(this.out); - } + /* + * tar-js + * MIT (c) 2011 T. Jameson Little + */ - return this.out; - }; + (function () { + "use strict"; - Tar.prototype.clear = function () { - this.written = 0; - this.out = utils.clean(blockSize); - }; - - module.exports = Tar; -}()); + var header = __webpack_require__(1), + utils = __webpack_require__(0), + recordSize = 512, + blockSize; + function Tar(recordsPerBlock) { + this.written = 0; + blockSize = (recordsPerBlock || 20) * recordSize; + this.out = utils.clean(blockSize); + } -/***/ }) -/******/ ]); \ No newline at end of file + Tar.prototype.append = function (filepath, input, opts, callback) { + var data, + checksum, + mode, + mtime, + uid, + gid, + headerArr; + + if (typeof input === 'string') { + input = utils.stringToUint8(input); + } else if (input.constructor !== Uint8Array.prototype.constructor) { + throw 'Invalid input type. You gave me: ' + input.constructor.toString().match(/function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/)[1]; + } + + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + + opts = opts || {}; + + mode = opts.mode || parseInt('777', 8) & 0xfff; + mtime = opts.mtime || Math.floor(+new Date() / 1000); + uid = opts.uid || 0; + gid = opts.gid || 0; + + data = { + fileName: filepath, + fileMode: utils.pad(mode, 7), + uid: utils.pad(uid, 7), + gid: utils.pad(gid, 7), + fileSize: utils.pad(input.length, 11), + mtime: utils.pad(mtime, 11), + checksum: ' ', + type: opts.type || '0', + ustar: 'ustar ', + owner: opts.owner || '', + group: opts.group || '', + linkName: opts.linkname || '' + }; + + // calculate the checksum + checksum = 0; + Object.keys(data).forEach(function (key) { + var i, value = data[key], length; + + for (i = 0, length = value.length; i < length; i += 1) { + checksum += value.charCodeAt(i); + } + }); + + data.checksum = utils.pad(checksum, 6) + "\u0000 "; + + headerArr = header.format(data); + + var i, offset, length; + + this.out.set(headerArr, this.written); + + this.written += headerArr.length; + + // If there is not enough space in this.out, we need to expand it to + // fit the new input. + if (this.written + input.length > this.out.length) { + this.out = utils.extend(this.out, this.written, input.length, blockSize); + } + + this.out.set(input, this.written); + + // to the nearest multiple of recordSize + this.written += input.length + (recordSize - (input.length % recordSize || recordSize)); + + // make sure there's at least 2 empty records worth of extra space + if (this.out.length - this.written < recordSize * 2) { + this.out = utils.extend(this.out, this.written, recordSize * 2, blockSize); + } + + if (typeof callback === 'function') { + callback(this.out); + } + + return this.out; + }; + + Tar.prototype.clear = function () { + this.written = 0; + this.out = utils.clean(blockSize); + }; + + module.exports = Tar; + }()); + + + /***/ +}) +/******/]); \ No newline at end of file diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index a9be3ad..55697ed 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -50,7 +50,7 @@ const GRAFANA_ENDPOINT: string = 'http://' + window.location.hostname + ':3000'; // tslint:disable-next-line: typedef export const environment = { production: true, - packageSize: 15, + packageSize: 50, paginationNumber: 10, //Possible values are 10, 25, 50, 100 packageVersion: version, // tslint:disable-next-line: no-http-string diff --git a/src/environments/environment.ts b/src/environments/environment.ts index d2e5575..92b5193 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -50,7 +50,7 @@ const GRAFANA_ENDPOINT: string = 'http://' + window.location.hostname + ':3000'; // tslint:disable-next-line: typedef export const environment = { production: false, - packageSize: 15, + packageSize: 50, paginationNumber: 10, //Possible values are 10, 25, 50, 100 packageVersion: version, // tslint:disable-next-line: no-http-string diff --git a/src/models/CommonModel.ts b/src/models/CommonModel.ts index 627074b..fb9707a 100644 --- a/src/models/CommonModel.ts +++ b/src/models/CommonModel.ts @@ -152,6 +152,16 @@ export interface TARSETTINGS { buffer: ArrayBuffer; header_offset?: Number; size?: number; + linkname?: string; + uname?: string; + gname?: string; +} +/** Interface for File Settings */ +export interface FILESETTINGS { + 'type'?: string; + linkname?: string; + owner?: string; + group?: string; } /** Interface for Package information */ export interface PACKAGEINFO { diff --git a/src/services/SharedService.ts b/src/services/SharedService.ts index f2f730e..48fbb17 100644 --- a/src/services/SharedService.ts +++ b/src/services/SharedService.ts @@ -23,7 +23,7 @@ import { EventEmitter, Injectable, Output } from '@angular/core'; import { FormArray, FormGroup } from '@angular/forms'; import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; -import { CONSTANTNUMBER, ERRORDATA, GETAPIURLHEADER, PACKAGEINFO, PAGERSMARTTABLE, SMARTTABLECLASS, TARSETTINGS } from 'CommonModel'; +import { CONSTANTNUMBER, ERRORDATA, FILESETTINGS, GETAPIURLHEADER, PACKAGEINFO, PAGERSMARTTABLE, SMARTTABLECLASS, TARSETTINGS } from 'CommonModel'; import { environment } from 'environment'; import * as HttpStatus from 'http-status-codes'; import * as untar from 'js-untar'; @@ -194,14 +194,15 @@ export class SharedService { const getFoldersFiles: {}[] = extractedFiles; const folderNameStr: string = extractedFiles[0].name; getFoldersFiles.forEach((value: TARSETTINGS) => { + const fileValueObj: FILESETTINGS = this.createFileValueObject(value); const getRootFolder: string[] = value.name.split('/'); if (value.name.startsWith(folderNameStr) && (value.name.endsWith('.yaml') || value.name.endsWith('.yml')) && getRootFolder.length === this.directoryCount) { - tar.append(value.name, packageInfo.descriptor, { type: value.type }); + tar.append(value.name, packageInfo.descriptor, fileValueObj); } else { if (value.type !== 'L') { - tar.append(value.name, new Uint8Array(value.buffer), { type: value.type }); + tar.append(value.name, new Uint8Array(value.buffer), fileValueObj); } } }); @@ -224,6 +225,15 @@ export class SharedService { }); }); } + /** Method to return the file information @public */ + public createFileValueObject(value: TARSETTINGS): FILESETTINGS { + return { + type: value.type, + linkname: value.linkname, + owner: value.uname, + group: value.gname + }; + } /** Method to check given string is JSON or not @public */ public checkJson(jsonString: string): boolean { jsonString = jsonString.replace(/'/g, '"'); -- 2.17.1