Quellcode durchsuchen

Do not write the available file unnecessarily

Some times we need to write back the status file, but not the available
file. Add a new flag to handle those cases.

Based-on-patch-by: Michel Lespinasse <walken@zoy.org>
Guillem Jover vor 15 Jahren
Ursprung
Commit
9c01b37300
5 geänderte Dateien mit 5 neuen und 4 gelöschten Zeilen
  1. 1 1
      debian/changelog
  2. 1 1
      dselect/main.cc
  3. 1 1
      lib/dpkg/dbmodify.c
  4. 1 0
      lib/dpkg/dpkg-db.h
  5. 1 1
      src/select.c

+ 1 - 1
debian/changelog

@@ -41,7 +41,7 @@ dpkg (1.16.0) UNRELEASED; urgency=low
     instead of the last file acted on that directory.
   * Document in dpkg-query --help output and man page that --list and --show
     arguments are optionsl.
-  * Do not read the available file unnecessarily.
+  * Do not read and write the available file unnecessarily.
     Thanks to Michel Lespinasse <walken@zoy.org>. Closes: #397121
 
   [ Raphaël Hertzog ]

+ 1 - 1
dselect/main.cc

@@ -361,7 +361,7 @@ extern void operator delete(void *p) {
 
 urqresult urq_list(void) {
   readwrite = modstatdb_init(admindir, (modstatdb_rw)(msdbrw_writeifposs |
-                                                      msdbrw_available));
+                                                      msdbrw_available_readonly));
 
   curseson();
 

+ 1 - 1
lib/dpkg/dbmodify.c

@@ -285,7 +285,7 @@ void modstatdb_shutdown(void) {
   switch (cstatus) {
   case msdbrw_write:
     modstatdb_checkpoint();
-    if (cflags & msdbrw_available)
+    if (cflags & msdbrw_available && !(cflags & msdbrw_available_readonly))
       writedb(availablefile, 1, 0);
     /* Tidy up a bit, but don't worry too much about failure. */
     fclose(importanttmp);

+ 1 - 0
lib/dpkg/dpkg-db.h

@@ -219,6 +219,7 @@ enum modstatdb_rw {
   msdbrw_flagsmask= ~077,
   /* Flags start at 0100. */
   msdbrw_available = 0100,
+  msdbrw_available_readonly = 0200,
 };
 
 bool modstatdb_is_locked(const char *admindir);

+ 1 - 1
src/select.c

@@ -91,7 +91,7 @@ void setselections(const char *const *argv) {
   if (*argv)
     badusage(_("--%s takes no arguments"), cipaction->olong);
 
-  modstatdb_init(admindir, msdbrw_write | msdbrw_available);
+  modstatdb_init(admindir, msdbrw_write | msdbrw_available_readonly);
 
   lno= 1;
   for (;;) {