Skip to content

Commit

Permalink
chore: Rebuilds the whole thing
Browse files Browse the repository at this point in the history
  • Loading branch information
JirkaChadima committed Jun 28, 2018
1 parent 0945bcf commit 84f477d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
29 changes: 29 additions & 0 deletions examples/example_dapp_uploader/swarm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions lib/files.js
Expand Up @@ -6,7 +6,8 @@
var Q = require("bluebird");
var assert = require("assert");
var crypto = require("crypto");
var fs = require("fs-extra");
var fs = require("fs");
var fsp = require("fs-promise");
var got = require("got");
var mkdirp = require("mkdirp-promise");
var path = require("path");
Expand Down Expand Up @@ -101,13 +102,13 @@ var extract = function extract(fromPath) {
// Reads a file as an UTF8 string.
// Returns a promise containing that string.
var readUTF8 = function readUTF8(path) {
return fs.readFile(path, { encoding: "utf8" });
return fsp.readFile(path, { encoding: "utf8" });
};

// String ~> Promise Bool
var isDirectory = function isDirectory(path) {
return fs.exists(path).then(assert).then(function () {
return fs.lstat(path);
return fsp.exists(path).then(assert).then(function () {
return fsp.lstat(path);
}).then(function (stats) {
return stats.isDirectory();
}).catch(function () {
Expand All @@ -124,7 +125,7 @@ var directoryTree = function directoryTree(dirPath) {
var searchOnDir = function searchOnDir(dir) {
return search(path.join(dirPath, dir));
};
return Q.all(Q.map(fs.readdir(dirPath), searchOnDir));
return Q.all(Q.map(fsp.readdir(dirPath), searchOnDir));
} else {
paths.push(dirPath);
};
Expand Down Expand Up @@ -164,8 +165,8 @@ var safeDownloadArchived = function safeDownloadArchived(url) {
}).then(function () {
return filePath;
}).catch(function () {
return fs.exists(archiveDir).then(function (exists) {
return !exists ? fs.mkdir(archiveDir) : null;
return fsp.exists(archiveDir).then(function (exists) {
return !exists ? fsp.mkdir(archiveDir) : null;
}).then(function () {
return download(url)(archivePath).onData(promise.onDataCallback);
}).then(function () {
Expand All @@ -177,9 +178,9 @@ var safeDownloadArchived = function safeDownloadArchived(url) {
}).then(function () {
return search(new RegExp(fileName + "$"))(archiveDir);
}).then(function (fp) {
return fs.rename(fp[0], filePath);
return fsp.rename(fp[0], filePath);
}).then(function () {
return fs.unlink(archivePath);
return fsp.unlink(archivePath);
}).then(function () {
return fileHash ? checksum(fileHash)(filePath) : null;
}).then(function () {
Expand Down Expand Up @@ -247,4 +248,4 @@ module.exports = {
downloadArchived: downloadArchived,
search: search,
test: test
};
};
6 changes: 3 additions & 3 deletions lib/swarm.js
Expand Up @@ -68,7 +68,7 @@ module.exports = function (_ref) {
// String -> String -> String
var rawUrl = function rawUrl(swarmUrl) {
return function (hash) {
return swarmUrl + "/bzzr:/" + hash;
return swarmUrl + "/bzz-raw:/" + hash;
};
};

Expand Down Expand Up @@ -206,7 +206,7 @@ module.exports = function (_ref) {
// Returns a promise with the uploaded hash.
var uploadData = function uploadData(swarmUrl) {
return function (data) {
return request(swarmUrl + "/bzzr:/", {
return request(swarmUrl + "/bzz-raw:/", {
body: typeof data === "string" ? fromString(data) : data,
method: "POST" });
};
Expand Down Expand Up @@ -622,4 +622,4 @@ module.exports = function (_ref) {
fromString: fromString,
toString: toString
};
};
};

0 comments on commit 84f477d

Please sign in to comment.