CB-9413 Close RandomAccessStream once copied

This commit is contained in:
Murat Sutunc 2015-07-27 11:39:38 -07:00
parent eeb5880580
commit 110b3b3388

View File

@ -490,7 +490,7 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
return tempCapturedFile.openAsync(Windows.Storage.FileAccessMode.readWrite); return tempCapturedFile.openAsync(Windows.Storage.FileAccessMode.readWrite);
}) })
.then(function(fileStream) { .then(function(fileStream) {
return Windows.Storage.Streams.RandomAccessStream.copyAsync(finalStream, fileStream); return Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(finalStream, fileStream);
}) })
.done(function() { .done(function() {
photoStream.close(); photoStream.close();
@ -718,7 +718,7 @@ function savePhoto(picture, options, successCallback, errorCallback) {
resizeImageBase64(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight); resizeImageBase64(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight);
} else { } else {
fileIO.readBufferAsync(picture).done(function(buffer) { fileIO.readBufferAsync(picture).done(function(buffer) {
var strBase64 =encodeToBase64String(buffer); var strBase64 = encodeToBase64String(buffer);
picture.deleteAsync().done(function() { picture.deleteAsync().done(function() {
successCallback(strBase64); successCallback(strBase64);
}, function(err) { }, function(err) {