Skip to content

Commit

Permalink
Backport a bugfix for BrowserFS.configure caused by synchronous Creat…
Browse files Browse the repository at this point in the history
…e callbacks.

Previously, filesystems may not be created with the proper options.
  • Loading branch information
John Vilk committed Jul 24, 2017
1 parent 1d51975 commit e215d6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BrowserFS v1.4.1
# BrowserFS v1.4.2
> BrowserFS is an in-browser file system that emulates the [Node JS file system API](http://nodejs.org/api/fs.html) and supports storing and retrieving files from various backends. BrowserFS also integrates nicely into the Emscripten file system.
[![Build Status](https://travis-ci.org/jvilk/BrowserFS.svg?branch=master)](https://travis-ci.org/jvilk/BrowserFS)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browserfs",
"version": "1.4.1",
"version": "1.4.2",
"description": "A filesystem in your browser!",
"main": "dist/browserfs.js",
"typings": "dist/browserfs",
Expand Down
7 changes: 5 additions & 2 deletions src/core/browserfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ export function getFileSystem(config: FileSystemConfiguration, cb: BFSCallback<F
}
}
}

if (options !== null && typeof(options) === "object") {
let finishedIterating = false;
const props = Object.keys(options).filter((k) => k !== 'fs');

// Check recursively if other fields have 'fs' properties.
props.forEach((p) => {
const d = options[p];
if (d['fs']) {
if (d !== null && typeof(d) === "object" && d['fs']) {
waitCount++;
getFileSystem(d, function(e, fs?) {
waitCount--;
Expand All @@ -160,13 +162,14 @@ export function getFileSystem(config: FileSystemConfiguration, cb: BFSCallback<F
cb(e);
} else {
options[p] = fs;
if (waitCount === 0) {
if (waitCount === 0 && finishedIterating) {
finish();
}
}
});
}
});
finishedIterating = true;
}
if (waitCount === 0) {
finish();
Expand Down

0 comments on commit e215d6f

Please sign in to comment.