s/make_root_directory/ensure_root_directory/ and stop failing on existing node. Fixes #232.
This commit is contained in:
parent
f9b3b69588
commit
6716a1ff1a
|
@ -350,17 +350,21 @@ function set_extended_attribute (context, path_or_fd, name, value, flag, callbac
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* make_root_directory
|
* ensure_root_directory. Creates a root node if necessary.
|
||||||
|
*
|
||||||
|
* Note: this should only be invoked when formatting a new file system.
|
||||||
|
* Multiple invocations of this by separate instances will still result
|
||||||
|
* in only a single super node.
|
||||||
*/
|
*/
|
||||||
// Note: this should only be invoked when formatting a new file system
|
function ensure_root_directory(context, callback) {
|
||||||
function make_root_directory(context, callback) {
|
|
||||||
var superNode;
|
var superNode;
|
||||||
var directoryNode;
|
var directoryNode;
|
||||||
var directoryData;
|
var directoryData;
|
||||||
|
|
||||||
function write_super_node(error, existingNode) {
|
function ensure_super_node(error, existingNode) {
|
||||||
if(!error && existingNode) {
|
if(!error && existingNode) {
|
||||||
callback(new Errors.EEXIST());
|
// Another instance has beat us and already created the super node.
|
||||||
|
callback();
|
||||||
} else if(error && !(error instanceof Errors.ENOENT)) {
|
} else if(error && !(error instanceof Errors.ENOENT)) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
|
@ -388,7 +392,7 @@ function make_root_directory(context, callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.get(SUPER_NODE_ID, write_super_node);
|
context.get(SUPER_NODE_ID, ensure_super_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2010,7 +2014,7 @@ function ftruncate(fs, context, fd, length, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
makeRootDirectory: make_root_directory,
|
ensureRootDirectory: ensure_root_directory,
|
||||||
open: open,
|
open: open,
|
||||||
close: close,
|
close: close,
|
||||||
mknod: mknod,
|
mknod: mknod,
|
||||||
|
|
|
@ -206,7 +206,7 @@ function FileSystem(options, callback) {
|
||||||
complete(err);
|
complete(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
impl.makeRootDirectory(context, complete);
|
impl.ensureRootDirectory(context, complete);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue