Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 136700 | Differences between
and this patch

Collapse All | Expand All

(-)src/daemon/common/commonFile.ml (+12 lines)
Lines 450-455 Link Here
450
    None -> ()
450
    None -> ()
451
  | Some magic -> (as_file_impl file).impl_file_magic <- Some (HashMagic.merge files_magic magic)
451
  | Some magic -> (as_file_impl file).impl_file_magic <- Some (HashMagic.merge files_magic magic)
452
    
452
    
453
let check_magic file =
454
  let check file =
455
    match Magic.M.magic_fileinfo (file_disk_name file) false with
456
      None -> ()
457
    | Some magic -> set_file_magic file (Some magic)
458
  in
459
  let magic = file_magic file in
460
    match magic with
461
      None -> check file
462
    | Some magic when magic = "data" || magic = "empty" -> check file
463
    | _ -> ()
464
453
let set_file_last_seen file age =
465
let set_file_last_seen file age =
454
  let impl = as_file_impl file in
466
  let impl = as_file_impl file in
455
  impl.impl_file_last_seen <- age
467
  impl.impl_file_last_seen <- age
(-)src/daemon/common/commonFile.mli (-1 / +1 lines)
Lines 119-125 Link Here
119
val file_comment : CommonTypes.file -> string
119
val file_comment : CommonTypes.file -> string
120
val file_magic : CommonTypes.file -> string option
120
val file_magic : CommonTypes.file -> string option
121
val set_file_magic : CommonTypes.file -> string option -> unit
121
val set_file_magic : CommonTypes.file -> string option -> unit
122
  
122
val check_magic : CommonTypes.file -> unit  
123
val recover_bytes : CommonTypes.file -> (int64 * int64) list
123
val recover_bytes : CommonTypes.file -> (int64 * int64) list
124
val file_write : CommonTypes.file -> int64 -> string -> int -> int -> unit
124
val file_write : CommonTypes.file -> int64 -> string -> int -> int -> unit
125
val file_verify : CommonTypes.file ->
125
val file_verify : CommonTypes.file ->
(-)src/daemon/common/commonSwarming.ml (+1 lines)
Lines 1073-1078 Link Here
1073
let set_verified_chunk t i =
1073
let set_verified_chunk t i =
1074
  t.t_nverified_blocks <- t.t_nverified_blocks + 1;
1074
  t.t_nverified_blocks <- t.t_nverified_blocks + 1;
1075
  t.t_converted_verified_bitmap.[i] <- '3';
1075
  t.t_converted_verified_bitmap.[i] <- '3';
1076
  if i = 0 && !Autoconf.magic_works then check_magic t.t_file;
1076
  let s = t.t_s in
1077
  let s = t.t_s in
1077
  if t.t_primary then begin
1078
  if t.t_primary then begin
1078
    (* The primary is supposed to propagate verified chunks to the file *)
1079
    (* The primary is supposed to propagate verified chunks to the file *)
(-)src/daemon/driver/driverInteractive.ml (-17 lines)
Lines 123-145 Link Here
123
    close_log ()
123
    close_log ()
124
  end
124
  end
125
125
126
let file_magic_check () =
127
  if !Autoconf.magic_works then begin
128
    if !verbose then lprintf_nl "computing file magic values";
129
    let check_magic file =
130
      match Magic.M.magic_fileinfo (file_disk_name file) false with
131
        None -> ()
132
      | Some magic -> set_file_magic file (Some magic)
133
    in
134
    List.iter (fun file ->
135
      let magic = file_magic file in
136
      match magic with
137
        None -> check_magic file
138
      | Some magic when magic = "data" -> check_magic file
139
      | _ -> ()
140
    ) !!files
141
  end
142
143
(* ripped from gui_downloads *)
126
(* ripped from gui_downloads *)
144
127
145
let calc_file_eta f =
128
let calc_file_eta f =
(-)src/daemon/driver/driverMain.ml (-2 lines)
Lines 68-74 Link Here
68
68
69
let minute_timer () =
69
let minute_timer () =
70
  DriverInteractive.hdd_check ();
70
  DriverInteractive.hdd_check ();
71
  DriverInteractive.file_magic_check ();
72
  CommonShared.shared_check_files ();
71
  CommonShared.shared_check_files ();
73
  CommonUploads.upload_credit_timer ();
72
  CommonUploads.upload_credit_timer ();
74
  CommonInteractive.force_download_quotas ();
73
  CommonInteractive.force_download_quotas ();
Lines 436-442 Link Here
436
435
437
(*  lprintf "(1) CommonComplexOptions.load\n"; *)
436
(*  lprintf "(1) CommonComplexOptions.load\n"; *)
438
  CommonComplexOptions.load ();
437
  CommonComplexOptions.load ();
439
  DriverInteractive.file_magic_check ();
440
  CommonUploads.load ();
438
  CommonUploads.load ();
441
439
442
(*  lprintf "(2) CommonComplexOptions.load done\n"; *)
440
(*  lprintf "(2) CommonComplexOptions.load done\n"; *)
(-)src/networks/bittorrent/bTInteractive.ml (-28 / +12 lines)
Lines 256-269 Link Here
256
	  end in
256
	  end in
257
  print_first_tracker file.file_trackers;
257
  print_first_tracker file.file_trackers;
258
258
259
  let check_magic file =
260
    match Magic.M.magic_fileinfo file false with
261
      None -> None
262
    | Some s -> Some (HashMagic.merge CommonGlobals.files_magic s)
263
  in
259
  let cntr = ref 0 in
264
  let cntr = ref 0 in
260
  List.iter (fun (filename, size, magic) ->
265
  List.iter (fun (filename, size, _) ->
261
    Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ());
266
    Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ());
262
    let fs = Printf.sprintf "File %d" !cntr in
267
    let fs = Printf.sprintf "File %d" !cntr in
263
    let magic_string =
268
    let magic_string =
264
      match magic with
269
      if !Autoconf.magic_works then
270
	begin
271
          let subfile = Filename.concat (file_disk_name file) filename in
272
          match check_magic subfile with
265
        None -> ""
273
        None -> ""
266
      | Some magic -> Printf.sprintf " / %s" magic
274
      | Some magic -> Printf.sprintf " / %s" magic
275
	end
276
      else ""
267
    in
277
    in
268
    html_mods_td buf [
278
    html_mods_td buf [
269
      (fs, "sr br", fs);
279
      (fs, "sr br", fs);
Lines 623-654 Link Here
623
          lprintf_nl "ft_retry: exception %s" (Printexc2.to_string e)
633
          lprintf_nl "ft_retry: exception %s" (Printexc2.to_string e)
624
  ) ft_by_num
634
  ) ft_by_num
625
635
626
let file_magic_check () =
627
  if !Autoconf.magic_works then begin
628
    if !verbose then lprintf_nl "computing sub_file magic values";
629
    let check_magic file = 
630
      match Magic.M.magic_fileinfo file false with
631
        None -> None
632
      | Some s -> Some (HashMagic.merge CommonGlobals.files_magic s)
633
    in
634
    Hashtbl.iter (fun _ file ->
635
      let updated = ref false in
636
      let new_file_files = ref [] in
637
      List.iter (fun (filename, size, magic) ->
638
        let subfile = Filename.concat (file_disk_name file) filename in
639
        let new_magic =
640
          match magic with
641
            None -> check_magic subfile
642
          | Some magic when magic = "data" || magic = "empty" -> check_magic subfile
643
          | _ -> magic
644
        in
645
        if new_magic <> magic then updated := true;
646
        new_file_files := (filename, size, new_magic) :: !new_file_files
647
        ) file.file_files;
648
        if !updated then file.file_files <- !new_file_files
649
    ) files_by_uid
650
  end
651
652
let load_torrent_from_web r ft =
636
let load_torrent_from_web r ft =
653
  if !verbose then
637
  if !verbose then
654
      lprintf_nl "Loading torrent from web";
638
      lprintf_nl "Loading torrent from web";
(-)src/networks/bittorrent/bTMain.ml (-2 lines)
Lines 115-121 Link Here
115
    BTClients.recover_files ();
115
    BTClients.recover_files ();
116
    add_session_timer enabler 60.0 (fun timer ->
116
    add_session_timer enabler 60.0 (fun timer ->
117
        BTClients.recover_files ();
117
        BTClients.recover_files ();
118
        BTInteractive.file_magic_check ()
119
    );
118
    );
120
119
121
    add_session_timer enabler 120.0 (fun timer ->
120
    add_session_timer enabler 120.0 (fun timer ->
Lines 131-137 Link Here
131
	      ) !current_files;
130
	      ) !current_files;
132
  );
131
  );
133
132
134
  BTInteractive.file_magic_check ();
135
  BTClients.listen ();
133
  BTClients.listen ();
136
  ()
134
  ()
137
135

Return to bug 136700