Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7 from ubports/fix-path
Browse files Browse the repository at this point in the history
Fix custom paths
  • Loading branch information
NeoTheThird committed May 1, 2018
2 parents 42d134b + 5120f30 commit ab53532
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mount system";
const endCommands = "\nunmount system\n";
const DEFAULT_HOST = "https://system-image.ubports.com/";
const DEFAULT_CACHE_TIME = 180; // 3 minutes
const downloadPath = "./test";
const DEFAULT_PATH = "./test";
const ubuntuCommandFile = "ubuntu_command";
const ubuntuPushDir = "/cache/recovery/";
const gpg = ["image-signing.tar.xz", "image-signing.tar.xz.asc", "image-master.tar.xz", "image-master.tar.xz.asc"];
Expand All @@ -42,7 +42,7 @@ class Client {
constructor(options) {
this.host = DEFAULT_HOST;
this.cache_time = DEFAULT_CACHE_TIME;
this.path = downloadPath;
this.path = DEFAULT_PATH;
this.deviceIndex = {};
this.deviceIndexCache = 0;
this.channelsIndex = {};
Expand Down Expand Up @@ -95,10 +95,10 @@ class Client {
}

createInstallCommandsFile(cmds, device) {
if (!fs.existsSync(downloadPath + "/commandfile/")) {
mkdirp.sync(downloadPath + "/commandfile/");
if (!fs.existsSync(this.path + "/commandfile/")) {
mkdirp.sync(this.path + "/commandfile/");
}
var file = downloadPath + "/commandfile/" + ubuntuCommandFile + device + common.getRandomInt(1000, 9999);
var file = this.path + "/commandfile/" + ubuntuCommandFile + device + common.getRandomInt(1000, 9999);
fs.writeFileSync(file, cmds);
return file;
}
Expand Down Expand Up @@ -193,7 +193,7 @@ class Client {
gpg.forEach((g) => {
gpgUrls.push({
url: this.host + "gpg/" + g,
path: downloadPath + "gpg"
path: this.path + "/gpg"
});
});
return gpgUrls;
Expand All @@ -204,12 +204,12 @@ class Client {
index.files.forEach((file) => {
ret.push({
url: this.host + file.path,
path: downloadPath + "pool",
path: this.path + "/pool",
checksum: file.checksum
});
ret.push({
url: this.host + file.signature,
path: downloadPath + "pool"
path: this.path + "/pool"
});
});
return ret;
Expand Down
16 changes: 8 additions & 8 deletions tests/test-data/file-push.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[
{
"dest": "/cache/recovery/",
"src": "./testpool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz"
"src": "./test/pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./testpool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz.asc"
"src": "./test/pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz.asc"
},
{
"dest": "/cache/recovery/",
"src": "./testpool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz"
"src": "./test/pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./testpool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz.asc"
"src": "./test/pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz.asc"
},
{
"dest": "/cache/recovery/",
"src": "./testpool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz"
"src": "./test/pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./testpool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz.asc"
"src": "./test/pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz.asc"
},
{
"dest": "/cache/recovery/",
"src": "./testpool/version-261.tar.xz"
"src": "./test/pool/version-261.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./testpool/version-261.tar.xz.asc"
"src": "./test/pool/version-261.tar.xz.asc"
}
]
16 changes: 8 additions & 8 deletions tests/test-data/files-urls.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[
{
"checksum": "777b2d05b2a0f26b2a9a302eb7804e7eab9bf536f130ffae2f15455a80bd509b",
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz"
},
{
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz.asc"
},
{
"checksum": "234d719a32a01bc36d64dbb536fcf27d77957916f8c3851916e4d1e44d732364",
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz"
},
{
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz.asc"
},
{
"checksum": "5b6e870acf8944330acb2a9dad6f5270bd06c377603a3115f805290e989ab421",
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz"
},
{
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz.asc"
},
{
"checksum": "2624df95cbfc0c0dbdd0ff14a7cf6de78802bb38f5dd2a3fa75f0e99586dcba5",
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//ubports-touch/15.04/devel/bacon/version-261.tar.xz"
},
{
"path": "./testpool",
"path": "./test/pool",
"url": "https://system-image.ubports.com//ubports-touch/15.04/devel/bacon/version-261.tar.xz.asc"
}
]
8 changes: 4 additions & 4 deletions tests/unit-tests/test_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ describe('Client module', function() {
it("should return gpg urls array", function() {
const sic = new SystemImageClient();
expect(sic.getGgpUrlsArray()).to.eql([
{ "path": "./testgpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz" },
{ "path": "./testgpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz.asc" },
{ "path": "./testgpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz" },
{ "path": "./testgpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz.asc" }
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz" },
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz.asc" },
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz" },
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz.asc" }
]);
});
});
Expand Down

0 comments on commit ab53532

Please sign in to comment.