56 |
Once the block has been finished allow changing order. |
Once the block has been finished allow changing order. |
57 |
*) |
*) |
58 |
|
|
59 |
|
let lprintf_nl () = |
60 |
|
lprintf "%s[EDK]: " (log_time ()); lprintf_nl2 |
61 |
|
|
62 |
let sort_file_queue c = |
let sort_file_queue c = |
63 |
match c.client_download with |
match c.client_download with |
64 |
Some _ -> () |
Some _ -> () |
67 |
[] -> () |
[] -> () |
68 |
| [ (file, chunks, up) ] -> |
| [ (file, chunks, up) ] -> |
69 |
if !verbose_download || c.client_debug then begin |
if !verbose_download || c.client_debug then begin |
70 |
lprintf "sort_file_queue: single file. client(%d): %s, file(%d): %s\n" (client_num c) c.client_name (file_num file) (file_best_name file); |
lprintf_nl () "sort_file_queue: single file. client(%d): %s, file(%d): %s" (client_num c) c.client_name (file_num file) (file_best_name file); |
71 |
end |
end |
72 |
| (file, chunks, up) :: _ -> |
| (file, chunks, up) :: _ -> |
73 |
let fn = file_num file in |
let fn = file_num file in |
74 |
if !verbose_download || c.client_debug then begin |
if !verbose_download || c.client_debug then begin |
75 |
lprintf "sort_file_queue: multiple files. client(%d): %s, file(%d): %s\n" (client_num c) c.client_name (file_num file) (file_best_name file); |
lprintf_nl () "sort_file_queue: multiple files. client(%d): %s, file(%d): %s" (client_num c) c.client_name (file_num file) (file_best_name file); |
76 |
end; |
end; |
77 |
c.client_file_queue <- List.stable_sort (fun (f1, _, _) (f2, _, _) -> |
c.client_file_queue <- List.stable_sort (fun (f1, _, _) (f2, _, _) -> |
78 |
let v = file_priority f2 - file_priority f1 in |
let v = file_priority f2 - file_priority f1 in |
90 |
| (file, chunks, _) :: _ -> |
| (file, chunks, _) :: _ -> |
91 |
if (file_num file) <> fn then begin |
if (file_num file) <> fn then begin |
92 |
if !verbose_download || c.client_debug then begin |
if !verbose_download || c.client_debug then begin |
93 |
lprintf "sort_file_queue: queue change. client(%d): %s, file(%d): %s\n" (client_num c) c.client_name (file_num file) (file_best_name file); |
lprintf_nl () "sort_file_queue: queue change. client(%d): %s, file(%d): %s" (client_num c) c.client_name (file_num file) (file_best_name file); |
94 |
end; |
end; |
95 |
(* |
(* |
96 |
(* c.client_chunks <- chunks; *) |
(* c.client_chunks <- chunks; *) |
116 |
None -> () |
None -> () |
117 |
| Some s -> |
| Some s -> |
118 |
if !verbose_share then |
if !verbose_share then |
119 |
lprintf_nl "EDK: unshare_file %s" file.file_diskname; |
lprintf_nl () "unshare_file %s" file.file_diskname; |
120 |
file.file_shared <- None; |
file.file_shared <- None; |
121 |
decr nshared_files; |
decr nshared_files; |
122 |
CommonShared.shared_calculate_total_bytes (); |
CommonShared.shared_calculate_total_bytes (); |
178 |
|
|
179 |
let downloaded = Int64Swarmer.downloaded swarmer in |
let downloaded = Int64Swarmer.downloaded swarmer in |
180 |
if file_downloaded file <> downloaded then begin |
if file_downloaded file <> downloaded then begin |
181 |
lprintf "ERROR: file_downloaded file (%Ld) <> downloaded swarmer (%Ld)\n" |
lprintf_nl () "ERROR: file_downloaded file (%Ld) <> downloaded swarmer (%Ld)" |
182 |
(file_downloaded file) downloaded |
(file_downloaded file) downloaded |
183 |
end; |
end; |
184 |
|
|
185 |
if verified then begin |
if verified then begin |
186 |
if (file_size file <> downloaded) |
if (file_size file <> downloaded) |
187 |
then |
then |
188 |
lprintf "DonkeyOneFile: Downloaded size differs after complete verification\n"; |
lprintf_nl () "Downloaded size differs after complete verification"; |
189 |
download_finished file |
download_finished file |
190 |
end |
end |
191 |
|
|
395 |
let request_slot c = |
let request_slot c = |
396 |
if c.client_slot = SlotNotAsked then begin |
if c.client_slot = SlotNotAsked then begin |
397 |
if !verbose_download then begin |
if !verbose_download then begin |
398 |
lprintf "start_download...\n"; |
lprintf_nl () "start_download"; |
399 |
end; |
end; |
400 |
do_if_connected c.client_source.DonkeySources.source_sock (fun sock -> |
do_if_connected c.client_source.DonkeySources.source_sock (fun sock -> |
401 |
sort_file_queue c; |
sort_file_queue c; |
415 |
match c.client_download with |
match c.client_download with |
416 |
None -> |
None -> |
417 |
if !verbose_hidden_errors then |
if !verbose_hidden_errors then |
418 |
lprintf "DonkeyOneFile.block_received: block received but no file !\n Received: %s\n" (Md4.to_string md4) |
lprintf_nl ()"block_received: block received but no file !\n Received: %s" (Md4.to_string md4) |
419 |
| Some (file, up) -> |
| Some (file, up) -> |
420 |
|
|
421 |
if file.file_md4 <> md4 then begin |
if file.file_md4 <> md4 then begin |
422 |
if !verbose_hidden_errors then |
if !verbose_hidden_errors then |
423 |
lprintf "DonkeyOneFile.block_received: block for bad file\n Received: %s\n Expected: %s\n" (Md4.to_string md4) (Md4.to_string file.file_md4) |
lprintf_nl () "block_received: block for bad file\n Received: %s\n Expected: %s" (Md4.to_string md4) (Md4.to_string file.file_md4) |
424 |
end else begin |
end else begin |
425 |
DonkeySources.set_request_result c.client_source file.file_sources File_upload; |
DonkeySources.set_request_result c.client_source file.file_sources File_upload; |
426 |
|
|
471 |
|
|
472 |
if new_downloaded -- old_downloaded < len64 then |
if new_downloaded -- old_downloaded < len64 then |
473 |
if !verbose_download then begin |
if !verbose_download then begin |
474 |
lprintf "ALREADY RECEIVED: %Ld < %Ld\n" |
lprintf_nl () "ALREADY RECEIVED: %Ld < %Ld" |
475 |
(new_downloaded -- old_downloaded) len64; |
(new_downloaded -- old_downloaded) len64; |
476 |
end; |
end; |
477 |
get_from_client c |
get_from_client c |