Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/Commands/UploadCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ class UploadCommand extends Command {
onFileProgress: (localPath, chunk) => {
if (bar) {
bytesDispatched += chunk.length;
bytesUploaded += bytesDispatched;
bytesUploaded += chunk.length;

let message = `Uploading '${localPath}'`,
timeDiff = Date.now() - lastRun;

if (timeDiff >= this.config.get('cli.progressInterval') || bytesUploaded >= localFilesize) {
lastRun = Date.now();
bytesDispatched = 0;
bar.tick(chunk.length, {
bar.tick(bytesDispatched, {
speed: `${Utils.convertFileSize(Math.round(bytesDispatched * 1000 / timeDiff), 2)}/s`
});
message += `\n${bar.lastDraw}`;
logUpdate(message);
bytesDispatched = 0;
}
}
},
Expand Down Expand Up @@ -146,6 +146,7 @@ class UploadCommand extends Command {
});
}


Node.uploadFile(localPath, remotePath, opts, (err, data) => {
if (err) {
return reject(err);
Expand Down
13 changes: 7 additions & 6 deletions lib/Utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

let fs = require('fs'),
crypto = require('crypto');
crypto = require('crypto'),
path = require('path');

class Utils {
static convertFileSize(bytes, decimals = 2) {
Expand Down Expand Up @@ -85,12 +86,12 @@ class Utils {
return path;
}

static getPathArray(path) {
static getPathArray(remotePath) {
let retval = [];
path = path.split('/');
for (let i = 0; i < path.length; i++) {
if (path[i]) {
retval.push(path[i]);
remotePath = remotePath.split('/');
for (let i = 0; i < remotePath.length; i++) {
if (remotePath[i]) {
retval.push(path.basename(remotePath[i]));
}
}

Expand Down