193 |
|
|
194 |
let already_done = Failure "File already downloaded (use 'force_download' if necessary)" |
let already_done = Failure "File already downloaded (use 'force_download' if necessary)" |
195 |
|
|
196 |
|
let no_download_to_force = Failure "No forceable download found" |
197 |
|
|
198 |
|
let already_downloading = Failure "File is already in download queue" |
199 |
|
|
200 |
let really_query_download filenames size md4 location old_file absents = |
let really_query_download filenames size md4 location old_file absents = |
201 |
|
|
202 |
begin |
begin |
312 |
as_file file |
as_file file |
313 |
|
|
314 |
let query_download filenames size md4 location old_file absents force = |
let query_download filenames size md4 location old_file absents force = |
315 |
|
if force then |
316 |
(* TODO RESULT |
if !forceable_download = [] then |
317 |
if not force then |
raise no_download_to_force |
318 |
List.iter (fun m -> |
else |
319 |
if m = md4 then begin |
begin |
320 |
let r = try |
let f = List.hd !forceable_download in |
321 |
DonkeyIndexer.find_result md4 |
forceable_download := []; |
322 |
with _ -> |
really_query_download f.result_names f.result_size md4 None None None |
323 |
(* OK, we temporary create a result corresponding to the |
end |
324 |
file that should have been download, but has already been downloaded *) |
else |
325 |
|
begin |
326 |
|
try |
327 |
let r = { |
let file = find_file md4 in |
328 |
result_num = 0; |
(* jave TODO: if a user currently not downloading this file is requesting the download add this user |
329 |
result_network = network.network_num; |
to the list of users currently downloading this file *) |
330 |
result_md4 = md4; |
forceable_download := []; |
331 |
result_names = filenames; |
raise already_downloading |
332 |
result_size = size; |
with Not_found -> |
333 |
result_tags = []; |
begin |
334 |
result_type = ""; |
if List.mem md4 !!old_files then begin |
335 |
result_format = ""; |
(* copy file info into result for later usage in force_download *) |
336 |
result_comment = ""; |
let r = { |
337 |
result_done = false; |
result_num = 0; |
338 |
} in |
result_uids = [Uid.create (Ed2k md4)]; |
339 |
DonkeyIndexer.index_result_no_filter r |
result_names = filenames; |
340 |
in |
result_size = size; |
341 |
aborted_download := Some (result_num (as_result r.result_result)); |
result_tags = []; |
342 |
raise already_done |
result_type = ""; |
343 |
end) |
result_format = ""; |
344 |
!!old_files; *) |
result_comment = ""; |
345 |
really_query_download filenames size md4 location old_file absents |
result_done = false; |
346 |
|
result_force = true; (* marker for force_download *) |
347 |
|
result_time = 0; |
348 |
|
result_modified = false; |
349 |
|
} in |
350 |
|
forceable_download := [r]; |
351 |
|
raise already_done |
352 |
|
end |
353 |
|
else |
354 |
|
begin |
355 |
|
forceable_download := []; |
356 |
|
really_query_download filenames size md4 location old_file absents |
357 |
|
end |
358 |
|
end |
359 |
|
end |
360 |
|
|
361 |
let result_download r filenames force = |
let result_download r filenames force = |
362 |
let rec iter uids = |
let rec iter uids = |
1002 |
(Printf.sprintf "client %s unknown" iddest) |
(Printf.sprintf "client %s unknown" iddest) |
1003 |
); |
); |
1004 |
network.op_network_download <- (fun r -> |
network.op_network_download <- (fun r -> |
1005 |
result_download r r.result_names false |
result_download r r.result_names r.result_force |
1006 |
) |
) |
1007 |
|
|
1008 |
module P = GuiTypes |
module P = GuiTypes |