improved support for nested data directories

pull/1/head
ansuz 6 years ago
parent babb91686d
commit 0a1971cfee

@ -2,6 +2,7 @@
/* jshint esversion: 6 */
/* global Buffer */
var Fs = require("fs");
var Fse = require("fs-extra");
var Path = require("path");
var nThen = require("nthen");
const ToPull = require('stream-to-pull-stream');
@ -189,7 +190,7 @@ var checkPath = function (path, callback) {
return;
}
// 511 -> octal 777
Fs.mkdir(Path.dirname(path), 511, function (err) {
Fse.mkdirp(Path.dirname(path), 511, function (err) {
if (err && err.code !== 'EEXIST') {
callback(err);
return;
@ -420,7 +421,7 @@ module.exports.create = function (
};
// 0x1ff -> 777
var it;
Fs.mkdir(env.root, 0x1ff, function (err) {
Fse.mkdirp(env.root, 0x1ff, function (err) {
if (err && err.code !== 'EEXIST') {
// TODO: somehow return a nice error
throw err;

@ -1,9 +1,4 @@
var Fs = require("fs");
var Path = require("path");
var nacl = require("tweetnacl");
var nThen = require("nthen");
var Tasks = module.exports;
var Fs = require("fs
var encode = function (time, command, args) {
if (typeof(time) !== 'number') { return null; }
@ -58,8 +53,8 @@ var write = function (env, task, cb) {
var dir = id.slice(0, 2);
var dirpath = Path.join(env.root, dir);
Fs.mkdir(dirpath, 0x1ff, w(function (err) {
if (err && err.code !== 'EEXIST') {
Fse.mkdirp(dirpath, 0x1ff, w(function (err) {
if (err) {
return void cb(err);
}
}));
@ -78,7 +73,7 @@ Tasks.create = function (config, cb) {
};
// make sure the path exists...
Fs.mkdir(env.root, 0x1ff, function (err) {
Fse.mkdirp(env.root, 0x1ff, function (err) {
if (err && err.code !== 'EEXIST') {
throw err;
}
@ -91,4 +86,3 @@ Tasks.create = function (config, cb) {
});
};

Loading…
Cancel
Save