085132
From b4d103c6dec2aa0f8461e1ca78ad23d692e68d36 Mon Sep 17 00:00:00 2001
085132
From: Matthew Almond <malmond@fb.com>
085132
Date: Thu, 20 May 2021 13:35:13 -0700
085132
Subject: [PATCH] Add option --skip-filelists
085132
085132
This is a site-local optimization. Some packages and repos include an
085132
enormous number of files. This is extremely expensive if said repo is
085132
also fast changing.
085132
085132
Impact of skipping filelists: breaking ability to resolve file/path
085132
based dependencies, `-f` (file ownership) and `-l` (list) options in
085132
repoquery.
085132
---
085132
 doc/createrepo_c.8  | 3 +++
085132
 src/cmd_parser.c    | 2 ++
085132
 src/cmd_parser.h    | 1 +
085132
 src/createrepo_c.c  | 1 +
085132
 src/dumper_thread.c | 5 +++++
085132
 src/dumper_thread.h | 1 +
085132
 src/parsehdr.c      | 3 ++-
085132
 src/parsehdr.h      | 1 +
085132
 8 files changed, 16 insertions(+), 1 deletion(-)
085132
085132
diff --git a/doc/createrepo_c.8 b/doc/createrepo_c.8
085132
index e9b3fc2..10702f4 100644
085132
--- a/doc/createrepo_c.8
085132
+++ b/doc/createrepo_c.8
085132
@@ -213,5 +213,8 @@ Exit with retval 2 if there were any errors during processing
085132
 .SS \-\-ignore\-lock
085132
 .sp
085132
 Expert (risky) option: Ignore an existing .repodata/. (Remove the existing .repodata/ and create an empty new one to serve as a lock for other createrepo instances. For the repodata generation, a different temporary dir with the name in format .repodata.time.microseconds.pid/ will be used). NOTE: Use this option on your own risk! If two createrepos run simultaneously, then the state of the generated metadata is not guaranteed \- it can be inconsistent and wrong.
085132
+.SS \-\-skip\-filelists
085132
+.sp
085132
+Expert (risky) option: Skip filelist generation.
085132
 .\" Generated by docutils manpage writer.
085132
 .
085132
diff --git a/src/cmd_parser.c b/src/cmd_parser.c
085132
index bbefa08..0ecf7f9 100644
085132
--- a/src/cmd_parser.c
085132
+++ b/src/cmd_parser.c
085132
@@ -224,6 +224,8 @@ static GOptionEntry expert_entries[] =
085132
       "own risk! If two createrepos run simultaneously, then the state of the "
085132
       "generated metadata is not guaranteed - it can be inconsistent and wrong.",
085132
       NULL },
085132
+    { "skip-filelists", 0, 0, G_OPTION_ARG_NONE, &(_cmd_options.skip_filelists),
085132
+      "Expert (risky) option: Skip filelist generation.", NULL},
085132
     { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL },
085132
 };
085132
 
085132
diff --git a/src/cmd_parser.h b/src/cmd_parser.h
085132
index 32bcf99..5eff9d9 100644
085132
--- a/src/cmd_parser.h
085132
+++ b/src/cmd_parser.h
085132
@@ -57,6 +57,7 @@ struct CmdOptions {
085132
     char *general_compress_type;/*!< which compression type to use (even for
085132
                                      primary, filelists and other xml) */
085132
     gboolean skip_symlinks;     /*!< ignore symlinks of packages */
085132
+    gboolean skip_filelists;    /*!< Skip creating filelists */
085132
     gint changelog_limit;       /*!< number of changelog messages in
085132
                                      other.(xml|sqlite) */
085132
     gboolean unique_md_filenames;       /*!< include the file checksums in
085132
diff --git a/src/createrepo_c.c b/src/createrepo_c.c
085132
index f4f4544..9dd288e 100644
085132
--- a/src/createrepo_c.c
085132
+++ b/src/createrepo_c.c
085132
@@ -1253,6 +1253,7 @@ main(int argc, char **argv)
085132
     user_data.checksum_type     = cmd_options->checksum_type;
085132
     user_data.checksum_cachedir = cmd_options->checksum_cachedir;
085132
     user_data.skip_symlinks     = cmd_options->skip_symlinks;
085132
+    user_data.skip_filelists    = cmd_options->skip_filelists;
085132
     user_data.repodir_name_len  = strlen(in_dir);
085132
     user_data.task_count        = task_count;
085132
     user_data.package_count     = 0;
085132
diff --git a/src/dumper_thread.c b/src/dumper_thread.c
085132
index 119f3bd..f7c4e35 100644
085132
--- a/src/dumper_thread.c
085132
+++ b/src/dumper_thread.c
085132
@@ -431,6 +431,11 @@ cr_dumper_thread(gpointer data, gpointer user_data)
085132
     if (udata->checksum_cachedir)
085132
         hdrrflags = CR_HDRR_LOADHDRID | CR_HDRR_LOADSIGNATURES;
085132
 
085132
+
085132
+    // Load filelists, unless --skip-filelists is passed.
085132
+    if (udata->skip_filelists)
085132
+        hdrrflags |= CR_HDRR_SKIPFILES;
085132
+
085132
     // Get stat info about file
085132
     if (udata->old_metadata && !(udata->skip_stat)) {
085132
         if (stat(task->full_path, &stat_buf) == -1) {
085132
diff --git a/src/dumper_thread.h b/src/dumper_thread.h
085132
index 60f984d..654991f 100644
085132
--- a/src/dumper_thread.h
085132
+++ b/src/dumper_thread.h
085132
@@ -66,6 +66,7 @@ struct UserData {
085132
     cr_ChecksumType checksum_type;  // Constant representing selected checksum
085132
     const char *checksum_cachedir;  // Dir with cached checksums
085132
     gboolean skip_symlinks;         // Skip symlinks
085132
+    gboolean skip_filelists;        // Skip filelists
085132
     long task_count;                // Total number of task to process
085132
     long package_count;             // Total number of packages processed
085132
 
085132
diff --git a/src/parsehdr.c b/src/parsehdr.c
085132
index 2775bf3..97bb01e 100644
085132
--- a/src/parsehdr.c
085132
+++ b/src/parsehdr.c
085132
@@ -253,7 +253,8 @@ cr_package_from_header(Header hdr,
085132
         assert(x == dir_count);
085132
     }
085132
 
085132
-    if (headerGet(hdr, RPMTAG_FILENAMES,  full_filenames,  flags) &&
085132
+    if (!(hdrrflags & CR_HDRR_SKIPFILES) &&
085132
+        headerGet(hdr, RPMTAG_FILENAMES,  full_filenames,  flags) &&
085132
         headerGet(hdr, RPMTAG_DIRINDEXES, indexes,  flags) &&
085132
         headerGet(hdr, RPMTAG_BASENAMES,  filenames, flags) &&
085132
         headerGet(hdr, RPMTAG_FILEFLAGS,  fileflags, flags) &&
085132
diff --git a/src/parsehdr.h b/src/parsehdr.h
085132
index 032acca..e7a4a4a 100644
085132
--- a/src/parsehdr.h
085132
+++ b/src/parsehdr.h
085132
@@ -39,6 +39,7 @@ typedef enum {
085132
     CR_HDRR_NONE            = (1 << 0),
085132
     CR_HDRR_LOADHDRID       = (1 << 1), /*!< Load hdrid */
085132
     CR_HDRR_LOADSIGNATURES  = (1 << 2), /*!< Load siggpg and siggpg */
085132
+    CR_HDRR_SKIPFILES       = (1 << 3), /*!< Skip filelists */
085132
 } cr_HeaderReadingFlags;
085132
 
085132
 /** Read data from header and return filled cr_Package structure.