texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Atomic dir update


From: Gavin D. Smith
Subject: branch master updated: Atomic dir update
Date: Sat, 03 Dec 2022 14:18:50 -0500

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new c9055dc06a Atomic dir update
c9055dc06a is described below

commit c9055dc06a8bd9a9c3c1ce7262ec97501297c816
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Dec 3 19:18:40 2022 +0000

    Atomic dir update
    
    * install-info/install-info.c (output_dirfile):
    If rename to dir file failed, try deleting target file
    and try again.  From Eli.
---
 ChangeLog                   |  8 ++++++++
 install-info/install-info.c | 15 ++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index dc36bbcc1b..6cad8ce8f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-12-03  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       Atomic dir update
+
+       * install-info/install-info.c (output_dirfile):
+       If rename to dir file failed, try deleting target file
+       and try again.  From Eli.
+
 2022-12-03  Gavin Smith  <gavinsmith0123@gmail.com>
 
        Clickable section title in @contents for PDF
diff --git a/install-info/install-info.c b/install-info/install-info.c
index ef73a8855d..58bffacdb0 100644
--- a/install-info/install-info.c
+++ b/install-info/install-info.c
@@ -1054,7 +1054,20 @@ output_dirfile (char *dirfile, int dir_nlines, struct 
line_data *dir_lines,
   /* Update dir file atomically.  This stops the dir file being corrupted
      if install-info is interrupted. */
   if (rename (tempname, dirfile) == -1)
-    perror (tempname);
+    {
+      /* Try to delete target file and try again.  On some platforms you
+         may not rename to an existing file. */
+      if (remove (dirfile) == -1)
+        {
+          perror (dirfile);
+          remove (tempname);
+        }
+      else if (rename (tempname, dirfile) == -1)
+        {
+          perror (tempname);
+          remove (tempname);
+        }
+    }
 }
 
 /* Read through the input LINES, to find the section names and the



reply via email to

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