- do not autoload unneded repodata
authorMichael Schroeder <mls@suse.de>
Mon, 13 Jul 2009 15:36:33 +0000 (17:36 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 13 Jul 2009 15:36:33 +0000 (17:36 +0200)
- add repo_write_stdkeyfilter function

ext/repo_write.c
ext/repo_write.h

index 6d48942..46dfbdb 100644 (file)
@@ -956,6 +956,42 @@ static Id subfilekeys[] = {
 };
 #endif
 
+static Id verticals[] = {
+  SOLVABLE_AUTHORS,
+  SOLVABLE_DESCRIPTION,
+  SOLVABLE_MESSAGEDEL,
+  SOLVABLE_MESSAGEINS,
+  SOLVABLE_EULA,
+  SOLVABLE_DISKUSAGE,
+  SOLVABLE_FILELIST,
+  0
+};
+
+static char *languagetags[] = {
+  "solvable:summary:",
+  "solvable:description:",
+  "solvable:messageins:",
+  "solvable:messagedel:",
+  "solvable:eula:",
+  0
+};
+
+int
+repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata)
+{
+  const char *keyname;
+  int i;
+
+  for (i = 0; verticals[i]; i++)
+    if (key->name == verticals[i])
+      return KEY_STORAGE_VERTICAL_OFFSET;
+  keyname = id2str(repo->pool, key->name);
+  for (i = 0; languagetags[i] != 0; i++)
+    if (!strncmp(keyname, languagetags[i], strlen(languagetags[i])))
+      return KEY_STORAGE_VERTICAL_OFFSET;
+  return KEY_STORAGE_INCORE;
+}
+
 /*
  * Repo
  */
@@ -1087,6 +1123,11 @@ repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void
       for (j = 1; j < data->nkeys; j++, n++)
        {
          key = data->keys + j;
+         if (key->name == REPOSITORY_SOLVABLES && key->type == REPOKEY_TYPE_FLEXARRAY)
+           {
+             cbdata.keymap[n] = cbdata.keymap[key->name];
+             continue;
+           }
          /* see if we already had this one, should use hash for fast miss */
          for (k = 0; k < cbdata.nmykeys; k++)
            {
@@ -1260,7 +1301,11 @@ for (i = 1; i < cbdata.nmykeys; i++)
   /* collect all other data from all repodatas */
   /* XXX: merge arrays of equal keys? */
   for (j = 0, data = repo->repodata; j < repo->nrepodata; j++, data++)
-    repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_needed, &cbdata);
+    {
+      if (!repodataused[j])
+       continue;
+      repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_needed, &cbdata);
+    }
   sp = cbdata.sp;
   /* add solvables if needed */
   if (repo->nsolvables)
@@ -1582,7 +1627,11 @@ fprintf(stderr, "dir %d used %d\n", i, cbdata.dirused ? cbdata.dirused[i] : 1);
 
 #if 1
   for (j = 0, data = repo->repodata; j < repo->nrepodata; j++, data++)
-    repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_adddata, &cbdata);
+    {
+      if (!repodataused[j])
+       continue;
+      repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_adddata, &cbdata);
+    }
 #endif
 
   if (xd->len - cbdata.lastlen > cbdata.maxdata)
index fd622d4..5fc9bf2 100644 (file)
 
 #include <stdio.h>
 
-#include "pool.h"
 #include "repo.h"
 
-/* Describes a repodata file */
-typedef struct _Repodatafile
-{
-  /* These have the same meaning as the equally named fields in
-     Repodata.  */
-  char *location;
-  char *checksum;
-  unsigned int nchecksum;
-  unsigned int checksumtype;
-  struct _Repokey *keys;
-  unsigned int nkeys;
-  Id *addedfileprovides;
-  unsigned char *rpmdbcookie;
-} Repodatafile;
-
 void repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Id **keyarrayp);
+int repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata);
 
 #endif