Skip to content

Commit

Permalink
FileDownloader: use the buffer reading technique instead of line reading
Browse files Browse the repository at this point in the history
  • Loading branch information
birros committed Dec 10, 2017
1 parent 795e34d commit 6c2477c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/utils/file-downloader.vala
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ public class WebArchives.FileDownloader : Object {
try {
FileInputStream inputstream = file.read ();
DataInputStream dis = new DataInputStream (inputstream);
string line;

while ((line = yield dis.read_line_async ()) != null) {
current_length += line.length + 1;
uint8[] buffer = new uint8[100];
ssize_t size;
while ((size = yield dis.read_async (buffer)) > 0) {
current_length += size;

try {
dos.put_string (line + "\n");
dos.write (buffer[0:size]);
} catch (Error e) {
warning (e.message);
}
Expand Down

0 comments on commit 6c2477c

Please sign in to comment.