From 773de173821f0412903f8b6989f16241a3ce0f3d Mon Sep 17 00:00:00 2001 From: Samy Lange Date: Fri, 21 Sep 2018 22:43:23 +0200 Subject: [PATCH 1/4] Use Map "has" method so that an undefined filesMap is correctly detected. --- sources/osgPlugins/ReaderWriterZIP.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/osgPlugins/ReaderWriterZIP.js b/sources/osgPlugins/ReaderWriterZIP.js index eb9405b94..21007f418 100644 --- a/sources/osgPlugins/ReaderWriterZIP.js +++ b/sources/osgPlugins/ReaderWriterZIP.js @@ -22,9 +22,9 @@ ReaderWriterZIP.prototype = { var self = this; if (options && options.filesMap !== undefined) { // it comes from drag'n drop - if (options.filesMap[url] !== undefined) { + if (options.filesMap.has(url) !== undefined) { // Now url is a File - var file = options.filesMap[url]; + var file = options.filesMap.get(url); return this.readZipFile(file).then(function() { if (!self._fileName) return P.reject(self); // At this point we have the main file name and a Map containing all the resources From 52c0bd892a76be2b06e67a4e23a0459e36e68eb8 Mon Sep 17 00:00:00 2001 From: Samy Lange Date: Fri, 21 Sep 2018 22:45:30 +0200 Subject: [PATCH 2/4] Register unzipped files in readerWriterZIP so that readNodeUrl doesn't try to load them from the server. --- sources/osgPlugins/ReaderWriterZIP.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/osgPlugins/ReaderWriterZIP.js b/sources/osgPlugins/ReaderWriterZIP.js index 21007f418..ac21bb58f 100644 --- a/sources/osgPlugins/ReaderWriterZIP.js +++ b/sources/osgPlugins/ReaderWriterZIP.js @@ -64,6 +64,9 @@ ReaderWriterZIP.prototype = { break; } } + + this._filesMap = filesMap; + }.bind(this) ); } From 47f02e7dd21b0ad489050c1efdb361196da89247 Mon Sep 17 00:00:00 2001 From: Samy Lange Date: Fri, 21 Sep 2018 22:46:22 +0200 Subject: [PATCH 3/4] Return a promise when needed. It fixes the loading of some zip files. --- sources/osgPlugins/ReaderWriterZIP.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/osgPlugins/ReaderWriterZIP.js b/sources/osgPlugins/ReaderWriterZIP.js index ac21bb58f..e32abaed5 100644 --- a/sources/osgPlugins/ReaderWriterZIP.js +++ b/sources/osgPlugins/ReaderWriterZIP.js @@ -40,7 +40,7 @@ ReaderWriterZIP.prototype = { }); return filePromise.then(function(zfile) { - self.readZipFile(zfile).then(function() { + return self.readZipFile(zfile).then(function() { // At this point we have the main file name and a Map containing all the resources return ReaderParser.readNodeURL(self._fileName, { filesMap: self._filesMap @@ -50,7 +50,7 @@ ReaderWriterZIP.prototype = { }, readZipFile: function(fileOrBlob) { - fileHelper.unzip(fileOrBlob).then( + return fileHelper.unzip(fileOrBlob).then( function(filesMap) { for (var fileName in filesMap) { var extension = fileHelper.getExtension(fileName); From 72f9c13e504b5c3c068b4281ca89425fb705c81a Mon Sep 17 00:00:00 2001 From: Samy Lange Date: Mon, 31 Dec 2018 14:59:16 +0100 Subject: [PATCH 4/4] Fix code style. --- sources/osgPlugins/ReaderWriterZIP.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/sources/osgPlugins/ReaderWriterZIP.js b/sources/osgPlugins/ReaderWriterZIP.js index e32abaed5..30313f071 100644 --- a/sources/osgPlugins/ReaderWriterZIP.js +++ b/sources/osgPlugins/ReaderWriterZIP.js @@ -64,9 +64,7 @@ ReaderWriterZIP.prototype = { break; } } - this._filesMap = filesMap; - }.bind(this) ); }