Skip to content

Commit 074a9d2

Browse files
tinchoz49mafintosh
authored andcommitted
Fixed destroy method (#1)
* Fixed destroy method * Set toDestroy during opening entry file process
1 parent bdc84a0 commit 074a9d2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
package-lock.json

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function createFile (name, opts) {
3030
var fs = null
3131
var file = null
3232
var entry = null
33+
var toDestroy = null
3334
var readers = []
3435
var writers = []
3536

@@ -55,13 +56,15 @@ function createFile (name, opts) {
5556
}
5657

5758
function destroy (req) {
58-
entry.remove(ondone, onerror)
59+
toDestroy.remove(ondone, onerror)
5960

6061
function ondone () {
62+
toDestroy = null
6163
req.callback(null, null)
6264
}
6365

6466
function onerror (err) {
67+
toDestroy = null
6568
req.callback(err, null)
6669
}
6770
}
@@ -73,7 +76,7 @@ function createFile (name, opts) {
7376
fs = res
7477
mkdirp(parentFolder(name), function () {
7578
fs.root.getFile(name, {create: true}, function (e) {
76-
entry = e
79+
entry = toDestroy = e
7780
entry.file(function (f) {
7881
file = f
7982
req.callback(null)

0 commit comments

Comments
 (0)