[Pkg-privacy-commits] [torbrowser-launcher] 27/476: got it to finally save data to disk, but it's way too slow an inefficient. sadly, I might need to port it back to python.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:21:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository torbrowser-launcher.

commit b8198c25501c1006bf19f2569330161f5163c3f2
Author: Micah Lee <micahflee at riseup.net>
Date:   Thu Feb 14 18:03:44 2013 -0800

    got it to finally save data to disk, but it's way too slow an inefficient. sadly, I might need to port it back to python.
---
 src/torbrowser-launcher | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/torbrowser-launcher b/src/torbrowser-launcher
index 7f6623b..8c127e3 100755
--- a/src/torbrowser-launcher
+++ b/src/torbrowser-launcher
@@ -385,8 +385,8 @@ const TorBrowserLauncher = new Lang.Class({
     let bytes_so_far = 0;
 
     // open the file
-    let file = Gio.file_new_for_path(path);
-    let fstream = file.replace(null, false, Gio.FileCreateFlags.NONE, null);
+    var f = Gio.file_new_for_path(String(path));
+    var data_out = new Gio.DataOutputStream({base_stream:f.replace(null, false, Gio.FileCreateFlags.NONE, null)});
 
     // create an http message
     let request = Soup.Message.new('GET', url);
@@ -398,10 +398,11 @@ const TorBrowserLauncher = new Lang.Class({
     
     // update progress bar with each chunk
     request.connect('got_chunk', Lang.bind(this, function(message, chunk){
-      print(chunk[0]);
-      print('== start ==');
-      fstream.write(chunk, chunk.length, null);
-      print('== finish ==');
+      // write chunk to file
+      let data = chunk.get_data();
+      for(let i=0; i<chunk.length; i++) {
+        data_out.put_byte(data[i], null);
+      }
 
       bytes_so_far += chunk.length;
 
@@ -412,10 +413,10 @@ const TorBrowserLauncher = new Lang.Class({
         this._statusbar.set_label("Downloading "+name+": "+percent+"% ("+file_size(bytes_so_far)+" / "+file_size(total_size)+")");
       }
     }));
-    
+
     this._httpSession.queue_message(request, function(_httpSession, message) {
       // close the file
-      fstream.close(null);
+      data_out.close(null);
 
       if(message.status_code !== 200) {
         that._statusbar.set_label('Downloading '+name+' failed: '+message.status_code);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torbrowser-launcher.git



More information about the Pkg-privacy-commits mailing list