Skip to content

Commit

Permalink
Fixing #271
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzapp committed Mar 14, 2019
1 parent d7ea584 commit 6471979
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 213 deletions.
40 changes: 17 additions & 23 deletions plugins/api/server/Deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ class ApiDeployer extends HashBrown.Models.Deployer {
/**
* Tests this deployer
*
* @returns {Promise} Result
* @returns {String} Result
*/
test() {
return HashBrown.Helpers.RequestHelper.request('get', this.getPath('/test'));
async test() {
return await HashBrown.Helpers.RequestHelper.request('get', this.getPath('/test'));
}

/**
* Gets a file
*
* @param {String} path
*
* @return {Promise} Promise
* @return {Object} File
*/
getFile(path) {
return HashBrown.Helpers.RequestHelper.request('get', path);
async getFile(path) {
return await HashBrown.Helpers.RequestHelper.request('get', path);
}

/**
* Gets a folder
*
* @param {String} path
*
* @returns {Promise} Result
* @returns {Object} Folder
*/
getFolder(path) {
return this.getFile(path);
async getFolder(path) {
return await this.getFile(path);
}

/**
Expand All @@ -66,42 +66,36 @@ class ApiDeployer extends HashBrown.Models.Deployer {
*
* @return {Promise} Promise
*/
setFile(path, base64) {
return HashBrown.Helpers.RequestHelper.request('post', path, base64);
async setFile(path, base64) {
await HashBrown.Helpers.RequestHelper.request('post', path, base64);
}

/**
* Rename file
*
* @param {String} path
* @param {String} name
*
* @return {Promise} Promise
*/
renameFile(path, name) {
return HashBrown.Helpers.RequestHelper.request('post', path, name);
async renameFile(path, name) {
await HashBrown.Helpers.RequestHelper.request('post', path, name);
}

/**
* Removes a file
*
* @param {String} path
*
* @return {Promise} Promise
*/
removeFile(path) {
return HashBrown.Helpers.RequestHelper.request('delete', path);
async removeFile(path) {
await HashBrown.Helpers.RequestHelper.request('delete', path);
}

/**
* Removes a folder
*
* @param {String} path
*
* @returns {Promise} Result
*/
removeFolder(path) {
return this.removeFile(path);
async removeFolder(path) {
await this.removeFile(path);
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/Common/Models/Deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ class Deployer extends Entity {
getPath(name, filename = '', ignoreRoot = false) {
let path = '';

if(!ignoreRoot) {
path = this.getRootPath();
}

if(this.paths[name]) {
path = Path.join(path, this.paths[name]);
}
Expand All @@ -71,6 +67,16 @@ class Deployer extends Entity {
path = Path.join(path, filename);
}

if(!ignoreRoot) {
let rootPath = this.getRootPath();

if(rootPath && rootPath[rootPath.length - 1] !== '/') {
rootPath += '/';
}

path = rootPath + path;
}

return path;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Server/Helpers/RequestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ class RequestHelper {

}
}

// Parse URL
url = URL.parse(url);

let headers = {
'Accept': '*/*',
'User-Agent': 'HashBrown CMS',
Expand Down
Loading

0 comments on commit 6471979

Please sign in to comment.