Browse Source

share, transfer: user friendly size formatting

bboozzoo/dbus-support-fileshare
Maciek Borzecki 8 years ago
parent
commit
d92bb2d8c4
3 changed files with 8 additions and 6 deletions
  1. +1
    -1
      src/mconnect/share.vala
  2. +6
    -4
      src/mconnect/transfer-download.vala
  3. +1
    -1
      src/mconnect/transfer.vala

+ 1
- 1
src/mconnect/share.vala View File

@ -75,7 +75,7 @@ class ShareHandler : Object, PacketHandlerInterface {
} }
string name = pkt.body.get_string_member("filename"); string name = pkt.body.get_string_member("filename");
debug("file: %s size: %lld", name, pkt.payload.size);
debug("file: %s size: %s", name, format_size(pkt.payload.size));
var t = new DownloadTransfer( var t = new DownloadTransfer(
new InetSocketAddress(dev.host, new InetSocketAddress(dev.host,


+ 6
- 4
src/mconnect/transfer-download.vala View File

@ -70,9 +70,11 @@ class DownloadTransfer : Object {
private void start_transfer() { private void start_transfer() {
this.transfer = new Transfer(this.conn.input_stream, this.transfer = new Transfer(this.conn.input_stream,
this.foutstream); this.foutstream);
this.transfer.progress.connect((t, p) => {
int percent = (int) (100.0 * ((double)p / (double)this.size));
debug("progress: %llu/%llu %d %%", p, this.size, percent);
this.transfer.progress.connect((t, done) => {
int percent = (int) (100.0 * ((double)done / (double)this.size));
debug("progress: %s/%s %d%%",
format_size(done), format_size(this.size), percent);
this.transferred = done;
}); });
this.transfer.transfer_async.begin(this.cancel, this.transfer.transfer_async.begin(this.cancel,
this.transfer_complete); this.transfer_complete);
@ -82,7 +84,7 @@ class DownloadTransfer : Object {
info("transfer finished"); info("transfer finished");
try { try {
var rcvd_bytes = this.transfer.transfer_async.end(res); var rcvd_bytes = this.transfer.transfer_async.end(res);
debug("transfer done, got %llu bytes", rcvd_bytes);
debug("transfer done, got %s", format_size(rcvd_bytes));
this.cleanup_success(); this.cleanup_success();


+ 1
- 1
src/mconnect/transfer.vala View File

@ -47,10 +47,10 @@ class Transfer : Object {
chunk_size = max_chunk_size; chunk_size = max_chunk_size;
} }
debug("transfer done, got %llu bytes", bytes_done);
this.from.close(); this.from.close();
this.to.close(); this.to.close();
debug("transfer done, got %llu bytes", format_size(bytes_done));
return bytes_done; return bytes_done;
} }


Loading…
Cancel
Save