Merge branch 'docker-fix-rename' into staging

pull/1/head
ansuz 7 years ago
commit fcc54a3c34

@ -10,7 +10,7 @@
"dependencies": { "dependencies": {
"chainpad-server": "~2.1.0", "chainpad-server": "~2.1.0",
"express": "~4.16.0", "express": "~4.16.0",
"mkdirp": "^0.5.1", "fs-extra": "^7.0.0",
"nthen": "~0.1.0", "nthen": "~0.1.0",
"pull-stream": "^3.6.1", "pull-stream": "^3.6.1",
"replify": "^1.2.0", "replify": "^1.2.0",

@ -7,13 +7,14 @@ var Nacl = require("tweetnacl");
/* globals process */ /* globals process */
var Fs = require("fs"); var Fs = require("fs");
var Fse = require("fs-extra");
var Path = require("path"); var Path = require("path");
var Https = require("https"); var Https = require("https");
const Package = require('./package.json'); const Package = require('./package.json');
const Pinned = require('./pinned'); const Pinned = require('./pinned');
const Saferphore = require("saferphore"); const Saferphore = require("saferphore");
const nThen = require("nthen"); const nThen = require("nthen");
const Mkdirp = require("mkdirp");
var RPC = module.exports; var RPC = module.exports;
@ -1054,7 +1055,7 @@ var upload_complete = function (Env, publicKey, id, cb) {
} }
// lol wut handle ur errors // lol wut handle ur errors
Fs.rename(oldPath, newPath, function (e) { Fse.move(oldPath, newPath, function (e) {
if (e) { if (e) {
WARN('rename', e); WARN('rename', e);
return void cb('RENAME_ERR'); return void cb('RENAME_ERR');
@ -1146,7 +1147,7 @@ var owned_upload_complete = function (Env, safeKey, cb) {
// flow is dumb and I need to guard against this which will never happen // flow is dumb and I need to guard against this which will never happen
// / *:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } * / // / *:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } * /
Fs.rename(oldPath, finalPath, w(function (e) { Fs.move(oldPath, finalPath, w(function (e) {
if (e) { if (e) {
w.abort(); w.abort();
return void cb(e.code); return void cb(e.code);
@ -1218,13 +1219,13 @@ var owned_upload_complete = function (Env, safeKey, id, cb) {
var finalOwnPath; var finalOwnPath;
nThen(function (w) { nThen(function (w) {
// make the requisite directory structure using Mkdirp // make the requisite directory structure using Mkdirp
Mkdirp(filePath, w(function (e /*, path */) { Fse.mkdirp(filePath, w(function (e /*, path */) {
if (e) { // does not throw error if the directory already existed if (e) { // does not throw error if the directory already existed
w.abort(); w.abort();
return void cb(e.code); return void cb(e.code);
} }
})); }));
Mkdirp(ownPath, w(function (e /*, path */) { Fse.mkdirp(ownPath, w(function (e /*, path */) {
if (e) { // does not throw error if the directory already existed if (e) { // does not throw error if the directory already existed
w.abort(); w.abort();
return void cb(e.code); return void cb(e.code);
@ -1254,7 +1255,7 @@ var owned_upload_complete = function (Env, safeKey, id, cb) {
// flow is dumb and I need to guard against this which will never happen // flow is dumb and I need to guard against this which will never happen
/*:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } */ /*:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } */
Fs.rename(oldPath, finalPath, w(function (e) { Fse.move(oldPath, finalPath, w(function (e) {
if (e) { if (e) {
// Remove the ownership file // Remove the ownership file
Fs.unlink(finalOwnPath, function (e) { Fs.unlink(finalOwnPath, function (e) {

Loading…
Cancel
Save