mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 00:03:45 +00:00
1. Fixed crash that could happen when you close a FD in fs.closeSync()
2. Added 'cancel' method/event to zip-writer.js 3. Fixed bug in Windows Zip-Writer when parsing basePath 4. Added ability to manually specify basePath in Zip-Writer
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -747,7 +747,7 @@ BOOL ILibDuktape_fs_read_WindowsSink(void *chain, HANDLE h, ILibWaitHandle_Error
|
||||
duk_push_heapptr(data->ctx, data->userBuffer); // [callback][this][err][bytesRead][buffer]
|
||||
data->callback = NULL;
|
||||
data->userBuffer = NULL;
|
||||
if (duk_pcall_method(data->ctx, 3) != 0) { ILibDuktape_Process_UncaughtExceptionEx(data->ctx, "fs.read.onCallack(): "); }
|
||||
if (duk_pcall_method(data->ctx, 3) != 0) { ILibDuktape_Process_UncaughtExceptionEx(ctx, "fs.read.onCallack(): "); }
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
return(FALSE);
|
||||
|
||||
@@ -49,7 +49,14 @@ function getBaseFolder(val)
|
||||
|
||||
for (i = 0; i < val.length; ++i)
|
||||
{
|
||||
test.push(val[i].split(D));
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
test.push(val[i].split('/').join('\\').split(D));
|
||||
}
|
||||
else
|
||||
{
|
||||
test.push(val[i].split(D));
|
||||
}
|
||||
}
|
||||
|
||||
if (val.length == 1)
|
||||
@@ -271,6 +278,13 @@ function write(options)
|
||||
}
|
||||
}
|
||||
});
|
||||
require('events').EventEmitter.call(ret, true)
|
||||
.createEvent('cancel')
|
||||
.addMethod('cancel', function(callback)
|
||||
{
|
||||
this._cancel = true;
|
||||
if(callback!=null) { this.once('cancel', callback); }
|
||||
});
|
||||
ret._currentPosition = 0;
|
||||
ret._ObjectID = 'zip-writer.duplexStream';
|
||||
ret.bufferMode = 1;
|
||||
@@ -282,11 +296,30 @@ function write(options)
|
||||
ret.pause();
|
||||
|
||||
options._localFileTable = {};
|
||||
options._baseFolder = getBaseFolder(options.files);
|
||||
|
||||
options._baseFolder = (options.basePath == null ? getBaseFolder(options.files) : options.basePath);
|
||||
if (options._baseFolder != '')
|
||||
{
|
||||
if (!options._baseFolder.endsWith(process.platform == 'win32' ? '\\' : '/')) { options._baseFolder += (process.platform == 'win32' ? '\\' : '/'); }
|
||||
}
|
||||
ret._uncompressedReadSink = function _uncompressedReadSink(err, bytesRead, buffer)
|
||||
{
|
||||
var self = _uncompressedReadSink.self;
|
||||
if(self._cancel)
|
||||
{
|
||||
self._compressor.end();
|
||||
self._compressor.unpipe();
|
||||
try
|
||||
{
|
||||
require('fs').closeSync(self._currentFD);
|
||||
}
|
||||
catch(e)
|
||||
{}
|
||||
|
||||
self.options.files.length = 0;
|
||||
self.emit('cancel');
|
||||
self.end();
|
||||
return;
|
||||
}
|
||||
if(bytesRead == 0)
|
||||
{
|
||||
// DONE
|
||||
|
||||
Reference in New Issue
Block a user