portree_kid 2020-07-28 12:22:47 +02:00
parent ed35aab63b
commit 1075e8d466
3 changed files with 37 additions and 5 deletions

View File

@ -204,7 +204,7 @@ You should have received a copy of the GNU General Public License along with FG
console.log('make a check worker: ', path.resolve(__dirname, 'check.js'))
const worker = new Worker(winURL)
worker.onError = function(e) {
worker.onerror = function(e) {
worker.terminate()
worker.view.max = 0
worker.view.checkDialogVisible = false

View File

@ -74,6 +74,16 @@
const worker = new Worker(winURL)
console.log(fileUrl('src/renderer/utils/worker.js'))
worker.onerror = function (e) {
console.error(e)
worker.terminate()
worker.scanning = false
worker.view.progress = 0
worker.view.max = 0
worker.view.worker = null
clearInterval(this.polling)
e.preventDefault()
}
worker.scanning = this.scanning
worker.max = this.max
@ -121,6 +131,16 @@
const worker = new Worker(winURL)
console.log(fileUrl('src/renderer/utils/worker.js'))
worker.onerror = function (e) {
console.error(e)
worker.terminate()
worker.scanning = false
worker.view.progress = 0
worker.view.max = 0
worker.view.worker = null
clearInterval(this.polling)
e.preventDefault()
}
worker.scanning = this.scanning
worker.max = this.max
@ -169,6 +189,16 @@
const worker = new Worker(winURL)
console.log(fileUrl('src/renderer/utils/worker.js'))
worker.onerror = function (e) {
console.error(e)
worker.terminate()
worker.scanning = false
worker.view.progress = 0
worker.view.max = 0
worker.view.worker = null
clearInterval(this.polling)
e.preventDefault()
}
this.scanning = true
worker.scanning = this.scanning
worker.max = this.max

View File

@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License along with FG
* @param {*} callback
*/
const { Debugger } = require("electron");
async function asyncForEach(array, callback) {
logger('info', "AsyncForEach Len " + array.length);
for (let index = 0; index < array.length; index++) {
@ -46,7 +48,7 @@ async function scanGroundnetFiles(p, features) {
try {
logger('info', 'Start Groundnets ' + p);
var files = traverseDir(p);
this.postMessage(['max', files.length]);
this.postMessage(['max', files.length*2]);
logger('info', files);
asyncForEach(files, async f => {
@ -376,6 +378,7 @@ function store(icao, airlines, value) {
async function readGroundnet(f, features) {
var promise = new Promise(function (resolve, reject) {
try {
var thisPostMessage = this.postMessage;
var filename = path.basename(f).match('^([^.]+)\\.([^.]+)(\\.new)?\\.([^.]+)');
if (filename == null) {
resolve("File didn't match");
@ -470,12 +473,10 @@ async function readGroundnet(f, features) {
}
if(filename [3] === '.new') {
feature['properties']['wipgroundnet'] = nodes && nodes.node ? nodes.node.length : 0;
//debugger;
feature['properties']['wipparking'] = parkingnodes && parkingnodes.Parking ? parkingnodes.Parking.length : 0;
} else {
feature['properties']['groundnet'] = nodes && nodes.node ? nodes.node.length : 0;
//debugger;
feature['properties']['parking'] = parkingnodes && parkingnodes.Parking ? parkingnodes.Parking.length : 0;
}
}
@ -490,6 +491,7 @@ async function readGroundnet(f, features) {
// report on the success of the transaction completing, when everything is done
transaction.oncomplete = function (event) {
logger('info', 'Write Transaction complete ' + event);
thisPostMessage(['progress', 1]);
resolve("Stored " + filename[1]);
};
@ -512,7 +514,7 @@ async function readGroundnet(f, features) {
};
}
objectStoreRequest.onerror = function (event) {
logger('info', "Read Errpr : " + event);
logger('info', "Read Error : " + event);
resolve(event);
}
}