[Po4a-commits] "po4a po4a,1.65,1.66 changelog,1.145,1.146"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Thu Nov 30 20:46:07 CET 2006


Update of /cvsroot/po4a/po4a
In directory alioth:/tmp/cvs-serv12181

Modified Files:
	po4a changelog 
Log Message:
Always write in a temporary file (even in force mode), just move the
temporary file at its final location (with move or move_po_if_needed).


Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- po4a	30 Nov 2006 19:38:17 -0000	1.65
+++ po4a	30 Nov 2006 19:46:05 -0000	1.66
@@ -818,20 +818,15 @@
             my $tmp_file;
             # Create a temporary PO, and check if the old one needs to be
             # updated (unless --force was specified).
-            unless ($po4a_opts{"force"}) {
-                (undef,$tmp_file)=File::Temp->tempfile("po4aXXXX",
-                                                       DIR    => "/tmp",
-                                                       SUFFIX => ".po",
-                                                       OPEN   => 0,
-                                                       UNLINK => 0)
-                    or die wrap_msg(
-                        gettext("Can't create a temporary pot file: %s"), $!);
-            }
+            (undef,$tmp_file)=File::Temp->tempfile("po4aXXXX",
+                                                   DIR    => "/tmp",
+                                                   SUFFIX => ".po",
+                                                   OPEN   => 0,
+                                                   UNLINK => 0)
+                or die wrap_msg(
+                    gettext("Can't create a temporary pot file: %s"), $!);
 
-            my $cmd = "msggrep -N '$master' -o ".
-                      ($po4a_opts{"force"}?$splitted_po{$lang}{$master}:
-                                           $tmp_file).
-                      " $po_filename{$lang}";
+            my $cmd = "msggrep -N '$master' -o $tmp_file $po_filename{$lang}";
             run_cmd($cmd);
 
             my $dir = dirname($splitted_po{$lang}{$master});
@@ -844,6 +839,23 @@
                 move_po_if_needed($tmp_file,
                                   $splitted_po{$lang}{$master},
                                   $po4a_opts{"no-backups"}?0:1);
+            } else {
+                if (    -f $splitted_po{$lang}{$master}
+                    and not $po4a_opts{"no-backups"}) {
+                    copy $splitted_po{$lang}{$master},
+                         $splitted_po{$lang}{$master}."~"
+                        or die wrap_msg(dgettext("po4a",
+                                                 "Can't copy %s to %s: %s."),
+                                        $splitted_po{$lang}{$master},
+                                        $splitted_po{$lang}{$master}."~",
+                                        $!);
+                }
+                move $tmp_file, $splitted_po{$lang}{$master}
+                    or die wrap_msg(dgettext("po4a",
+                                             "Can't move %s to %s: %s."),
+                                    $tmp_file,
+                                    $splitted_po{$lang}{$master},
+                                    $!);
             }
         }
     }

Index: changelog
===================================================================
RCS file: /cvsroot/po4a/po4a/changelog,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -d -r1.145 -r1.146
--- changelog	30 Nov 2006 19:38:17 -0000	1.145
+++ changelog	30 Nov 2006 19:46:05 -0000	1.146
@@ -12,6 +12,9 @@
 	to specify if we want a ~ backup file.
 	* po4a: Use the backup argument of move_po_if_needed: no backups
 	for temp files; no backups when the no-backups option is used.
+	* po4a: (Splitted mode) Always write in a temporary file, and at the
+	end, move it to the final location or use move_po_if_needed. This
+	was needed for the handling of backup files.
 
 2006-11-25  Nicolas François  <nicolas.francois at centraliens.net>
 




More information about the Po4a-commits mailing list