mldonkey-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-commits] mldonkey distrib/ChangeLog src/utils/lib/option...


From: mldonkey-commits
Subject: [Mldonkey-commits] mldonkey distrib/ChangeLog src/utils/lib/option...
Date: Thu, 06 Apr 2006 21:46:56 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Branch:         
Changes by:     spiralvoice <address@hidden>    06/04/06 21:46:56

Modified files:
        distrib        : ChangeLog 
        src/utils/lib  : options.ml4 

Log message:
        patch #5016

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/distrib/ChangeLog.diff?tr1=1.786&tr2=1.787&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/utils/lib/options.ml4.diff?tr1=1.19&tr2=1.20&r1=text&r2=text

Patches:
Index: mldonkey/distrib/ChangeLog
diff -u mldonkey/distrib/ChangeLog:1.786 mldonkey/distrib/ChangeLog:1.787
--- mldonkey/distrib/ChangeLog:1.786    Wed Apr  5 00:16:28 2006
+++ mldonkey/distrib/ChangeLog  Thu Apr  6 21:46:56 2006
@@ -14,6 +14,9 @@
 ChangeLog
 =========
 
+2006/04/06
+5016: Options save: Really fix bug addressed in patch #5015
+
 2006/04/05
 5015: Fix option file saving bug introduced in tryopen patch
 
Index: mldonkey/src/utils/lib/options.ml4
diff -u mldonkey/src/utils/lib/options.ml4:1.19 
mldonkey/src/utils/lib/options.ml4:1.20
--- mldonkey/src/utils/lib/options.ml4:1.19     Wed Apr  5 00:16:29 2006
+++ mldonkey/src/utils/lib/options.ml4  Thu Apr  6 21:46:56 2006
@@ -809,18 +809,14 @@
   
 let save opfile =
   opfile.file_before_save_hook ();
+
+  let old_config_dir = "old_config" in
+  if not (Sys.file_exists old_config_dir) then Unix.mkdir old_config_dir 0o755;
+
   let filename = opfile.file_name in
   let temp_file = filename ^ ".tmp" in
-  let old_file = 
-    let dirname = Filename.dirname filename in
-    let basename = Filename.basename filename in
-    let old_config = Filename.concat dirname "old_config" in
-    if not (Sys.file_exists old_config) then Unix.mkdir old_config 0o755;
-    let old_file = Filename.concat old_config basename in
-    let old_old_file = filename ^ ".old" in
-    if not (Sys.file_exists old_file) && (Sys.file_exists old_old_file) then
-      Sys.rename old_old_file old_file;
-    old_file in
+  let old_file = Filename.concat old_config_dir filename in
+
   try
     Unix2.tryopen_write temp_file (fun oc ->
       (* race! *)
@@ -906,8 +902,16 @@
           opfile.file_rc <- !rem
        end;
       Hashtbl.clear once_values_rev);
-    begin try Unix2.rename filename old_file with  _ -> () end;
-    begin try Unix2.rename temp_file filename with _ -> () end;
+    (try
+      begin
+        try
+          Unix2.rename filename old_file
+        with Unix.Unix_error(Unix.ENOENT, _, _) -> ();
+      end;
+      Unix2.rename temp_file filename
+     with e ->
+        lprintf_nl "[Opt] exception %s while saving %s" (Printexc2.to_string 
e) filename
+    );
     opfile.file_after_save_hook ();
   with e -> 
     opfile.file_after_save_hook ();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]