commit:     8134627701e2eea2a0eb590f6bd80064a2496ecf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 29 15:35:43 2017 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Nov 29 15:35:43 2017 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=81346277

hashgen: avoid empty Manifest references

 scripts/rsync-generation/hashgen.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/scripts/rsync-generation/hashgen.c 
b/scripts/rsync-generation/hashgen.c
index 68d5575ad2..034ea7f170 100644
--- a/scripts/rsync-generation/hashgen.c
+++ b/scripts/rsync-generation/hashgen.c
@@ -289,25 +289,28 @@ process_dir(const char *dir)
                hashes = newhashes;
        }
 
-       snprintf(manifest, sizeof(manifest), "%s/Manifest", dir);
+       snprintf(manifest, sizeof(manifest), "%s/%s", dir, str_manifest);
        if ((f = fopen(manifest, "r")) == NULL) {
                gzFile mf;
 
-               /* open up a gzipped Manifest to keep the hashes of the
-                * Manifests in the subdirs */
-               snprintf(manifest, sizeof(manifest), "%s/Manifest.gz", dir);
-               if ((mf = gzopen(manifest, "wb9")) == NULL) {
-                       fprintf(stderr, "failed to open file '%s' for writing: 
%s\n",
-                                       manifest, strerror(errno));
-                       return NULL;
-               }
-
                /* recurse into subdirs */
                if ((d = opendir(dir)) != NULL) {
                        struct stat s;
+
+                       /* open up a gzipped Manifest to keep the hashes of the
+                        * Manifests in the subdirs */
+                       snprintf(manifest, sizeof(manifest), "%s/%s", dir, 
str_manifest_gz);
+                       if ((mf = gzopen(manifest, "wb9")) == NULL) {
+                               fprintf(stderr, "failed to open file '%s' for 
writing: %s\n",
+                                               manifest, strerror(errno));
+                               return NULL;
+                       }
+
                        while ((e = readdir(d)) != NULL) {
                                if (e->d_name[0] == '.')
                                        continue;
+                               if (strcmp(e->d_name, str_manifest_gz) == 0)
+                                       continue;
                                snprintf(path, sizeof(path), "%s/%s", dir, 
e->d_name);
                                if (!stat(path, &s)) {
                                        if (s.st_mode & S_IFDIR) {
@@ -324,13 +327,13 @@ process_dir(const char *dir)
                                }
                        }
                        closedir(d);
-               }
 
-               gzclose(mf);
-               if (tv[0].tv_sec != 0) {
-                       /* restore dir mtime, and set Manifest mtime to match 
it */
-                       utimes(manifest, tv);
-                       utimes(dir, tv);
+                       gzclose(mf);
+                       if (tv[0].tv_sec != 0) {
+                               /* restore dir mtime, and set Manifest mtime to 
match it */
+                               utimes(manifest, tv);
+                               utimes(dir, tv);
+                       }
                }
 
                return str_manifest_gz;

Reply via email to