flow compliance

This commit is contained in:
ansuz 2018-07-19 10:33:01 +02:00
parent 3a6f7d9b36
commit a090dc52db
2 changed files with 7 additions and 8 deletions

View file

@ -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",

13
rpc.js
View file

@ -7,15 +7,14 @@ var Nacl = require("tweetnacl");
/* globals process */ /* globals process */
var Fs = require("fs"); var Fs = require("fs");
Fs.move = require('fs-extra').move;
Fs.moveSync = require('fs-extra').moveSync; 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;
@ -1056,7 +1055,7 @@ var upload_complete = function (Env, publicKey, id, cb) {
} }
// lol wut handle ur errors // lol wut handle ur errors
Fs.move(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');
@ -1220,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);
@ -1256,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.move(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) {