Skip to content

Commit

Permalink
fix(ios): set executionContext of TiStreamProxy (#12647)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28324
  • Loading branch information
build committed Mar 23, 2021
1 parent 6ffe8f9 commit a18fb68
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions iphone/Classes/FilesystemModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ - (JSValue *)openStream:(TiStreamMode)mode
if (fileProxy != nil) {
NSArray *payload = @[ [NSNumber numberWithInt:mode] ];
TiStreamProxy *streamProxy = [fileProxy open:payload];
streamProxy.executionContext = self.executionContext; //TIMOB-28324 Should we pass this executionContext in open function of TiFilesystemFileProxy?
if (streamProxy != nil) {
return [self NativeToJSValue:streamProxy];
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Resources/ti.stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,21 @@ describe('Titanium.Stream', function () {
totalsize = 0;
Ti.Stream.pump(blobStream, handler, chunksize, true);
});

it('pump - handler should be called(TIMOB-28324))', function (finish) {
var sourceFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'streamfile.txt'),
sourceFileStream = Ti.Filesystem.openStream(Ti.Filesystem.MODE_READ, sourceFile.nativePath),
handlerCalled = false;

function handler() {
handlerCalled = true;
}

Ti.Stream.pump(sourceFileStream, handler, 20);
if (handlerCalled) {
finish();
} else {
finish(Error('Ti.Stream.pump handler not called.'));
}
});
});

0 comments on commit a18fb68

Please sign in to comment.