133 |
in |
in |
134 |
match real_ext with |
match real_ext with |
135 |
".zip" -> |
".zip" -> |
136 |
begin try |
begin try |
137 |
let ic = Zip.open_in filename in |
let ic = Zip.open_in filename in |
138 |
try |
try |
139 |
let file = Zip.find_entry ic "server.met" in |
let file = Zip.find_entry ic "server.met" in |
140 |
Zip.close_in ic; |
Zip.close_in ic; |
141 |
lprintf_nl () "server.met found in %s" url; |
lprintf_nl () "server.met found in %s" url; |
142 |
let s = Misc.archive_extract filename "zip" in |
let s = Misc.archive_extract filename "zip" in |
143 |
file.Zip.filename |
file.Zip.filename |
144 |
with e -> |
with e -> |
145 |
Zip.close_in ic; |
Zip.close_in ic; |
146 |
lprintf_nl () "Exception %s while extracting server.met from %s" |
lprintf_nl () "Exception %s while extracting server.met from %s" |
147 |
(Printexc2.to_string e) url; |
(Printexc2.to_string e) url; |
148 |
raise Not_found |
raise Not_found |
149 |
with e -> |
with e -> |
150 |
lprintf_nl () "Exception %s while opening %s" |
lprintf_nl () "Exception %s while opening %s" |
151 |
(Printexc2.to_string e) url; |
(Printexc2.to_string e) url; |
152 |
raise Not_found |
raise Not_found |
153 |
end |
end |
154 |
| ".met.gz" | ".met.bz2" | ".gz" | ".bz2" -> |
| ".met.gz" | ".met.bz2" | ".gz" | ".bz2" -> |
155 |
begin |
begin |
156 |
let filetype = |
let filetype = |
157 |
if ext = ".bz2" || ext = ".met.bz2" then |
if ext = ".bz2" || ext = ".met.bz2" then |
158 |
"bz2" |
"bz2" |
159 |
else |
else |
160 |
"gz" |
"gz" |
161 |
in try |
in try |
162 |
let s = Misc.archive_extract filename filetype in |
let s = Misc.archive_extract filename filetype in |
163 |
s |
s |
164 |
with e -> |
with e -> |
165 |
lprintf_nl () "Exception %s while extracting from %s" |
lprintf_nl () "Exception %s while extracting from %s" |
166 |
(Printexc2.to_string e) url; |
(Printexc2.to_string e) url; |
167 |
raise Not_found |
raise Not_found |
168 |
end |
end |
169 |
(* if file is not a supported archive type try loading servers from that file anyway *) |
(* if file is not a supported archive type try loading servers from that file anyway *) |
170 |
| _ -> filename |
| _ -> filename |
171 |
|
|
177 |
H.req_url = Url.of_string url; |
H.req_url = Url.of_string url; |
178 |
H.req_proxy = !CommonOptions.http_proxy; |
H.req_proxy = !CommonOptions.http_proxy; |
179 |
H.req_user_agent = |
H.req_user_agent = |
180 |
Printf.sprintf "MLDonkey/%s" Autoconf.current_version; |
Printf.sprintf "MLDonkey/%s" Autoconf.current_version; |
181 |
H.req_max_retry = 10; |
H.req_max_retry = 10; |
182 |
} in |
} in |
183 |
H.wget r (fun filename -> |
H.wget r (fun filename -> |
184 |
try |
try |
185 |
let nservers = List.length (Hashtbl2.to_list servers_by_key) in |
let nservers = List.length (Hashtbl2.to_list servers_by_key) in |
186 |
let s = unpack_server_met filename url in |
let s = unpack_server_met filename url in |
187 |
let n = load_server_met s in |
let n = load_server_met s in |
188 |
if s <> filename then Sys.remove s; |
if s <> filename then Sys.remove s; |
189 |
lprintf_nl () "server.met loaded from %s, %d servers found, %d new ones inserted" |
lprintf_nl () "server.met loaded from %s, %d servers found, %d new ones inserted" |
190 |
url n ((List.length (Hashtbl2.to_list servers_by_key)) - nservers) |
url n ((List.length (Hashtbl2.to_list servers_by_key)) - nservers) |
191 |
with e -> () |
with e -> () |
192 |
) |
) |
193 |
|
|
632 |
|
|
633 |
"servers", Arg_one (fun filename o -> |
"servers", Arg_one (fun filename o -> |
634 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
635 |
if !!update_server_list_server_met then |
if !!update_server_list_server_met then |
636 |
begin |
begin |
637 |
let nservers = List.length (Hashtbl2.to_list servers_by_key) in |
let nservers = List.length (Hashtbl2.to_list servers_by_key) in |
638 |
if (String2.starts_with filename "http") then |
if (String2.starts_with filename "http") then |
639 |
begin |
begin |
640 |
ignore (download_server_met filename); |
ignore (download_server_met filename); |
641 |
Printf.sprintf "download of %s started, check log for results" filename |
Printf.sprintf "download of %s started, check log for results" filename |
642 |
end |
end |
643 |
else |
else |
644 |
if Sys.file_exists filename then begin |
if Sys.file_exists filename then begin |
645 |
let n = load_server_met filename in |
let n = load_server_met filename in |
646 |
Printf.sprintf "%d servers found, %d new ones inserted" |
Printf.sprintf "%d servers found, %d new ones inserted" |
647 |
n ((List.length (Hashtbl2.to_list servers_by_key)) - nservers) |
n ((List.length (Hashtbl2.to_list servers_by_key)) - nservers) |
648 |
end |
end |
649 |
else |
else |
650 |
Printf.sprintf "%s does not exist, ignoring..." filename |
Printf.sprintf "%s does not exist, ignoring..." filename |
651 |
end |
end |
652 |
else |
else |
653 |
Printf.sprintf "ED2K_update_server_list_met is disabled, ignoring..." |
Printf.sprintf "ED2K_update_server_list_met is disabled, ignoring..." |
654 |
), "<filename|URL> :\t\t\tadd the servers from a server.met file or URL"; |
), "<filename|URL> :\t\t\tadd the servers from a server.met file or URL"; |
655 |
|
|
656 |
"id", Arg_none (fun o -> |
"id", Arg_none (fun o -> |
766 |
( "0", "srh", "MD4 (link=ed2k)", "MD4 (link=ed2k)" ); ]; |
( "0", "srh", "MD4 (link=ed2k)", "MD4 (link=ed2k)" ); ]; |
767 |
|
|
768 |
|
|
769 |
end; |
end; |
770 |
|
|
771 |
List.iter (fun filename -> |
List.iter (fun filename -> |
772 |
incr counter; |
incr counter; |
794 |
try |
try |
795 |
let file = find_file md4 in |
let file = find_file md4 in |
796 |
if use_html_mods o then |
if use_html_mods o then |
797 |
let fnum = (file_num file) in |
let fnum = (file_num file) in |
798 |
Printf.bprintf buf " |
Printf.bprintf buf " |
799 |
\\<tr class=\\\"%s\\\"\\>\\<td class=\\\"sr\\\"\\> |
\\<tr class=\\\"%s\\\"\\>\\<td class=\\\"sr\\\"\\> |
800 |
\\<form name=\\\"renameForm%d\\\" id=\\\"renameForm%d\\\" action=\\\"javascript:submitRenameForm(%d);\\\"\\> |
\\<form name=\\\"renameForm%d\\\" id=\\\"renameForm%d\\\" action=\\\"javascript:submitRenameForm(%d);\\\"\\> |
801 |
\\<input style=\\\"font: 8pt sans-serif\\\" name=\\\"newName\\\" type=text size=50 value=\\\"%s\\\"\\>\\</input\\>\\</td\\>\\</form\\> |
\\<input style=\\\"font: 8pt sans-serif\\\" name=\\\"newName\\\" type=text size=50 value=\\\"%s\\\"\\>\\</input\\>\\</td\\>\\</form\\> |
802 |
\\<td class=\\\"sr \\\"\\>%s\\</td\\> |
\\<td class=\\\"sr \\\"\\>%s\\</td\\> |
803 |
\\<td class=\\\"sr \\\"\\>\\<A HREF=\\\"%s\\\"\\>%s\\</A\\>\\</td\\>\\</tr\\>" |
\\<td class=\\\"sr \\\"\\>\\<A HREF=\\\"%s\\\"\\>%s\\</A\\>\\</td\\>\\</tr\\>" |
804 |
!tr fnum fnum fnum (file_best_name file) "Downloading" (file_comment (as_file file)) filename |
!tr fnum fnum fnum (file_best_name file) "Downloading" (file_comment (as_file file)) filename |
1397 |
let _, qchunks,_ = List.find (fun (qfile, _,_) -> |
let _, qchunks,_ = List.find (fun (qfile, _,_) -> |
1398 |
qfile == file) qfiles in |
qfile == file) qfiles in |
1399 |
let tc = ref 0 in |
let tc = ref 0 in |
1400 |
|
let arr = Array.init (Bitv.length qchunks) |
1401 |
|
(fun i -> if Bitv.get qchunks i then begin incr tc; 2 end else 0) in |
1402 |
Printf.bprintf buf "%s\\</td\\>\\<td class=\\\"sr ar\\\"\\>%d\\</td\\>" |
Printf.bprintf buf "%s\\</td\\>\\<td class=\\\"sr ar\\\"\\>%d\\</td\\>" |
1403 |
(CommonFile.colored_chunks (Array.init (Array.length qchunks) |
(CommonFile.colored_chunks arr) !tc; |
|
(fun i -> (if qchunks.(i) then 2 else 0)) )) |
|
|
(Array.iter (fun b -> if b then incr tc) qchunks;!tc); |
|
1404 |
with Not_found -> ( |
with Not_found -> ( |
1405 |
Printf.bprintf buf "\\</td\\>\\<td class=\\\"sr ar\\\"\\>\\</td\\>" |
Printf.bprintf buf "\\</td\\>\\<td class=\\\"sr ar\\\"\\>\\</td\\>" |
1406 |
); |
); |
1690 |
if !!enable_donkey && !!update_server_list_server_met then |
if !!enable_donkey && !!update_server_list_server_met then |
1691 |
begin |
begin |
1692 |
lprintf_n () "server.met loaded from %s" url; |
lprintf_n () "server.met loaded from %s" url; |
1693 |
begin |
begin |
1694 |
try |
try |
1695 |
let s = unpack_server_met filename url in |
let s = unpack_server_met filename url in |
1696 |
let nservers = List.length (Hashtbl2.to_list servers_by_key) in |
let nservers = List.length (Hashtbl2.to_list servers_by_key) in |
1697 |
let n = load_server_met s in |
let n = load_server_met s in |
1698 |
if s <> filename then Sys.remove s; |
if s <> filename then Sys.remove s; |
1699 |
lprintf ", %d servers found, %d new ones inserted" |
lprintf ", %d servers found, %d new ones inserted" |
1700 |
n ((List.length (Hashtbl2.to_list servers_by_key)) - nservers) |
n ((List.length (Hashtbl2.to_list servers_by_key)) - nservers) |
1701 |
with _ -> () |
with _ -> () |
1702 |
end; |
end; |
1703 |
lprint_newline () |
lprint_newline () |
1704 |
end |
end |
1705 |
else |
else |