View | Details | Raw Unified
Collapse All | Expand All

(-) src/daemon/common/commonFile.ml (+12 lines)
 Lines 450-455    Link Here 
    None -> ()
    None -> ()
  | Some magic -> (as_file_impl file).impl_file_magic <- Some (HashMagic.merge files_magic magic)
  | Some magic -> (as_file_impl file).impl_file_magic <- Some (HashMagic.merge files_magic magic)
    
    
let check_magic file =
  let check file =
    match Magic.M.magic_fileinfo (file_disk_name file) false with
      None -> ()
    | Some magic -> set_file_magic file (Some magic)
  in
  let magic = file_magic file in
    match magic with
      None -> check file
    | Some magic when magic = "data" || magic = "empty" -> check file
    | _ -> ()
let set_file_last_seen file age =
let set_file_last_seen file age =
  let impl = as_file_impl file in
  let impl = as_file_impl file in
  impl.impl_file_last_seen <- age
  impl.impl_file_last_seen <- age
(-) src/daemon/common/commonFile.mli (-1 / +1 lines)
 Lines 119-125    Link Here 
val file_comment : CommonTypes.file -> string
val file_comment : CommonTypes.file -> string
val file_magic : CommonTypes.file -> string option
val file_magic : CommonTypes.file -> string option
val set_file_magic : CommonTypes.file -> string option -> unit
val set_file_magic : CommonTypes.file -> string option -> unit
  
val check_magic : CommonTypes.file -> unit  
val recover_bytes : CommonTypes.file -> (int64 * int64) list
val recover_bytes : CommonTypes.file -> (int64 * int64) list
val file_write : CommonTypes.file -> int64 -> string -> int -> int -> unit
val file_write : CommonTypes.file -> int64 -> string -> int -> int -> unit
val file_verify : CommonTypes.file ->
val file_verify : CommonTypes.file ->
(-) src/daemon/common/commonSwarming.ml (+1 lines)
 Lines 1073-1078    Link Here 
let set_verified_chunk t i =
let set_verified_chunk t i =
  t.t_nverified_blocks <- t.t_nverified_blocks + 1;
  t.t_nverified_blocks <- t.t_nverified_blocks + 1;
  t.t_converted_verified_bitmap.[i] <- '3';
  t.t_converted_verified_bitmap.[i] <- '3';
  if i = 0 && !Autoconf.magic_works then check_magic t.t_file;
  let s = t.t_s in
  let s = t.t_s in
  if t.t_primary then begin
  if t.t_primary then begin
    (* The primary is supposed to propagate verified chunks to the file *)
    (* The primary is supposed to propagate verified chunks to the file *)
(-) src/daemon/driver/driverInteractive.ml (-17 lines)
 Lines 123-145    Link Here 
    close_log ()
    close_log ()
  end
  end
let file_magic_check () =
  if !Autoconf.magic_works then begin
    if !verbose then lprintf_nl "computing file magic values";
    let check_magic file =
      match Magic.M.magic_fileinfo (file_disk_name file) false with
        None -> ()
      | Some magic -> set_file_magic file (Some magic)
    in
    List.iter (fun file ->
      let magic = file_magic file in
      match magic with
        None -> check_magic file
      | Some magic when magic = "data" -> check_magic file
      | _ -> ()
    ) !!files
  end
(* ripped from gui_downloads *)
(* ripped from gui_downloads *)
let calc_file_eta f =
let calc_file_eta f =
(-) src/daemon/driver/driverMain.ml (-2 lines)
 Lines 68-74    Link Here 
let minute_timer () =
let minute_timer () =
  DriverInteractive.hdd_check ();
  DriverInteractive.hdd_check ();
  DriverInteractive.file_magic_check ();
  CommonShared.shared_check_files ();
  CommonShared.shared_check_files ();
  CommonUploads.upload_credit_timer ();
  CommonUploads.upload_credit_timer ();
  CommonInteractive.force_download_quotas ();
  CommonInteractive.force_download_quotas ();
 Lines 436-442    Link Here 
(*  lprintf "(1) CommonComplexOptions.load\n"; *)
(*  lprintf "(1) CommonComplexOptions.load\n"; *)
  CommonComplexOptions.load ();
  CommonComplexOptions.load ();
  DriverInteractive.file_magic_check ();
  CommonUploads.load ();
  CommonUploads.load ();
(*  lprintf "(2) CommonComplexOptions.load done\n"; *)
(*  lprintf "(2) CommonComplexOptions.load done\n"; *)
(-) src/networks/bittorrent/bTInteractive.ml (-28 / +12 lines)
 Lines 256-269    Link Here 
	  end in
	  end in
  print_first_tracker file.file_trackers;
  print_first_tracker file.file_trackers;
  let check_magic file =
    match Magic.M.magic_fileinfo file false with
      None -> None
    | Some s -> Some (HashMagic.merge CommonGlobals.files_magic s)
  in
  let cntr = ref 0 in
  let cntr = ref 0 in
  List.iter (fun (filename, size, magic) ->
  List.iter (fun (filename, size, _) ->
    Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ());
    Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ());
    let fs = Printf.sprintf "File %d" !cntr in
    let fs = Printf.sprintf "File %d" !cntr in
    let magic_string =
    let magic_string =
      match magic with
      if !Autoconf.magic_works then
	begin
          let subfile = Filename.concat (file_disk_name file) filename in
          match check_magic subfile with
        None -> ""
        None -> ""
      | Some magic -> Printf.sprintf " / %s" magic
      | Some magic -> Printf.sprintf " / %s" magic
	end
      else ""
    in
    in
    html_mods_td buf [
    html_mods_td buf [
      (fs, "sr br", fs);
      (fs, "sr br", fs);
 Lines 623-654    Link Here 
          lprintf_nl "ft_retry: exception %s" (Printexc2.to_string e)
          lprintf_nl "ft_retry: exception %s" (Printexc2.to_string e)
  ) ft_by_num
  ) ft_by_num
let file_magic_check () =
  if !Autoconf.magic_works then begin
    if !verbose then lprintf_nl "computing sub_file magic values";
    let check_magic file = 
      match Magic.M.magic_fileinfo file false with
        None -> None
      | Some s -> Some (HashMagic.merge CommonGlobals.files_magic s)
    in
    Hashtbl.iter (fun _ file ->
      let updated = ref false in
      let new_file_files = ref [] in
      List.iter (fun (filename, size, magic) ->
        let subfile = Filename.concat (file_disk_name file) filename in
        let new_magic =
          match magic with
            None -> check_magic subfile
          | Some magic when magic = "data" || magic = "empty" -> check_magic subfile
          | _ -> magic
        in
        if new_magic <> magic then updated := true;
        new_file_files := (filename, size, new_magic) :: !new_file_files
        ) file.file_files;
        if !updated then file.file_files <- !new_file_files
    ) files_by_uid
  end
let load_torrent_from_web r ft =
let load_torrent_from_web r ft =
  if !verbose then
  if !verbose then
      lprintf_nl "Loading torrent from web";
      lprintf_nl "Loading torrent from web";
(-) src/networks/bittorrent/bTMain.ml (-2 lines)
 Lines 115-121    Link Here 
    BTClients.recover_files ();
    BTClients.recover_files ();
    add_session_timer enabler 60.0 (fun timer ->
    add_session_timer enabler 60.0 (fun timer ->
        BTClients.recover_files ();
        BTClients.recover_files ();
        BTInteractive.file_magic_check ()
    );
    );
    add_session_timer enabler 120.0 (fun timer ->
    add_session_timer enabler 120.0 (fun timer ->
 Lines 131-137    Link Here 
	      ) !current_files;
	      ) !current_files;
  );
  );
  BTInteractive.file_magic_check ();
  BTClients.listen ();
  BTClients.listen ();
  ()
  ()