Split out file state recording out of fsmMapPath()
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 24 Apr 2012 08:55:37 +0000 (11:55 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 24 Apr 2012 08:55:37 +0000 (11:55 +0300)
- The file state that gets stored in the rpmdb has nothing to do with
  path and is only relevant for installs.

lib/fsm.c

index ce8a202..b0e2e90 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -449,15 +449,6 @@ static int fsmMapPath(FSM_t fsm)
 
         if (rpmteType(te) == TR_ADDED) {
             switch (fsm->action) {
-            case FA_SKIPNSTATE:
-               rpmfsSetState(fs, i, RPMFILE_STATE_NOTINSTALLED);
-                break;
-            case FA_SKIPNETSHARED:
-               rpmfsSetState(fs, i, RPMFILE_STATE_NETSHARED);
-                break;
-            case FA_SKIPCOLOR:
-               rpmfsSetState(fs, i, RPMFILE_STATE_WRONGCOLOR);
-                break;
             case FA_ALTNAME:
                 if (!(fsm->fflags & RPMFILE_GHOST)) /* XXX Don't if %ghost file. */
                     fsm->nsuffix = SUFFIX_RPMNEW;
@@ -1691,6 +1682,24 @@ static const char * fileActionString(rpmFileAction a)
     }
 }
 
+/* Remember any non-regular file state for recording in the rpmdb */
+static void setFileState(rpmfs fs, int i, rpmFileAction action)
+{
+    switch (action) {
+    case FA_SKIPNSTATE:
+       rpmfsSetState(fs, i, RPMFILE_STATE_NOTINSTALLED);
+       break;
+    case FA_SKIPNETSHARED:
+       rpmfsSetState(fs, i, RPMFILE_STATE_NETSHARED);
+       break;
+    case FA_SKIPCOLOR:
+       rpmfsSetState(fs, i, RPMFILE_STATE_WRONGCOLOR);
+       break;
+    default:
+       break;
+    }
+}
+
 int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
               rpmpsm psm, char ** failedFile)
 {
@@ -1745,6 +1754,8 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
             break;
         }
 
+       setFileState(rpmteGetFileStates(te), fsm->ix, fsm->action);
+
         if (!fsm->postpone) {
             if (S_ISREG(st->st_mode)) {
                 char * path = fsm->path;