Merge branch 'master' of ssh://bitbucket.org/yackob03/quay
This commit is contained in:
commit
bac3a4ba4f
2 changed files with 40 additions and 9 deletions
|
@ -235,6 +235,26 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
};
|
};
|
||||||
|
|
||||||
dataFileService.tryAsTarGz_ = function(buf, success, failure) {
|
dataFileService.tryAsTarGz_ = function(buf, success, failure) {
|
||||||
|
var gunzip = new Zlib.Gunzip(buf);
|
||||||
|
var plain = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
plain = gunzip.decompress();
|
||||||
|
} catch (e) {
|
||||||
|
failure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataFileService.arrayToString(plain, function(result) {
|
||||||
|
if (result) {
|
||||||
|
dataFileService.tryAsTarGzWithStringData_(result, success, failure);
|
||||||
|
} else {
|
||||||
|
failure();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
dataFileService.tryAsTarGzWithStringData_ = function(strData, success, failure) {
|
||||||
var collapsePath = function(originalPath) {
|
var collapsePath = function(originalPath) {
|
||||||
// Tar files can contain entries of the form './', so we need to collapse
|
// Tar files can contain entries of the form './', so we need to collapse
|
||||||
// those paths down.
|
// those paths down.
|
||||||
|
@ -248,12 +268,9 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
return parts.join('/');
|
return parts.join('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
var gunzip = new Zlib.Gunzip(buf);
|
|
||||||
var plain = gunzip.decompress();
|
|
||||||
|
|
||||||
var handler = new MultiFile();
|
var handler = new MultiFile();
|
||||||
handler.files = [];
|
handler.files = [];
|
||||||
handler.processTarChunks(dataFileService.arrayToString(plain), 0);
|
handler.processTarChunks(strData, 0);
|
||||||
if (!handler.files.length) {
|
if (!handler.files.length) {
|
||||||
failure();
|
failure();
|
||||||
return;
|
return;
|
||||||
|
@ -288,8 +305,19 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
reader.readAsText(blob);
|
reader.readAsText(blob);
|
||||||
};
|
};
|
||||||
|
|
||||||
dataFileService.arrayToString = function(buf) {
|
dataFileService.arrayToString = function(buf, callback) {
|
||||||
return String.fromCharCode.apply(null, new Uint16Array(buf));
|
var bb = new Blob([buf], {type: 'application/octet-binary'});
|
||||||
|
var f = new FileReader();
|
||||||
|
f.onload = function(e) {
|
||||||
|
callback(e.target.result);
|
||||||
|
};
|
||||||
|
f.onerror = function(e) {
|
||||||
|
callback(null);
|
||||||
|
};
|
||||||
|
f.onabort = function(e) {
|
||||||
|
callback(null);
|
||||||
|
};
|
||||||
|
f.readAsText(bb);
|
||||||
};
|
};
|
||||||
|
|
||||||
dataFileService.readDataArrayAsPossibleArchive = function(buf, success, failure) {
|
dataFileService.readDataArrayAsPossibleArchive = function(buf, success, failure) {
|
||||||
|
|
|
@ -841,7 +841,7 @@ function BuildPackageCtrl($scope, Restangular, ApiService, DataFileService, $rou
|
||||||
if (dockerfile && dockerfile.canRead) {
|
if (dockerfile && dockerfile.canRead) {
|
||||||
DataFileService.blobToString(dockerfile.toBlob(), function(result) {
|
DataFileService.blobToString(dockerfile.toBlob(), function(result) {
|
||||||
$scope.$apply(function() {
|
$scope.$apply(function() {
|
||||||
$scope.dockerFilePath = dockerfilePath;
|
$scope.dockerFilePath = dockerfilePath || 'Dockerfile';
|
||||||
$scope.dockerFileContents = result;
|
$scope.dockerFileContents = result;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -851,8 +851,11 @@ function BuildPackageCtrl($scope, Restangular, ApiService, DataFileService, $rou
|
||||||
};
|
};
|
||||||
|
|
||||||
var notarchive = function() {
|
var notarchive = function() {
|
||||||
$scope.dockerFileContents = DataFileService.arrayToString(uint8array);
|
DataFileService.arrayToString(uint8array, function(r) {
|
||||||
$scope.loaded = true;
|
$scope.dockerFilePath = 'Dockerfile';
|
||||||
|
$scope.dockerFileContents = r;
|
||||||
|
$scope.loaded = true;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
DataFileService.readDataArrayAsPossibleArchive(uint8array, archiveread, notarchive);
|
DataFileService.readDataArrayAsPossibleArchive(uint8array, archiveread, notarchive);
|
||||||
|
|
Reference in a new issue