Prepare for killing the fsm: Move code for erasing files from FSM_COMMIT to FSM_ERASE
authorFlorian Festi <ffesti@redhat.com>
Wed, 28 Mar 2012 07:19:15 +0000 (09:19 +0200)
committerFlorian Festi <ffesti@redhat.com>
Fri, 30 Mar 2012 13:00:40 +0000 (15:00 +0200)
lib/fsm.c

index c52e09d..297ac2b 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1779,10 +1779,50 @@ static int fsmStage(FSM_t fsm, fileStage stage)
                break;
            }
 
-            if (!fsm->postpone) {
-                /* Rename/erase item. */
-               rc = fsmNext(fsm, FSM_COMMIT);
-            }
+            /* Remove erased files. */
+           if (!fsm->postpone && fsm->action == FA_ERASE) {
+               rpmte te = fsmGetTe(fsm);
+               if (S_ISDIR(st->st_mode)) {
+                   rc = fsmRmdir(fsm->path);
+                   if (!rc) break;
+                   switch (rc) {
+                   case CPIOERR_ENOENT: /* XXX rmdir("/") linux 2.2.x kernel hack */
+                   case CPIOERR_ENOTEMPTY:
+       /* XXX make sure that build side permits %missingok on directories. */
+                       if (fsm->fflags & RPMFILE_MISSINGOK)
+                           break;
+
+                       /* XXX common error message. */
+                       rpmlog(
+                           (strict_erasures ? RPMLOG_ERR : RPMLOG_DEBUG),
+                           _("%s rmdir of %s failed: Directory not empty\n"),
+                               rpmteTypeString(te), fsm->path);
+                       break;
+                   default:
+                       rpmlog(
+                           (strict_erasures ? RPMLOG_ERR : RPMLOG_DEBUG),
+                               _("%s rmdir of %s failed: %s\n"),
+                               rpmteTypeString(te), fsm->path, strerror(errno));
+                       break;
+                   }
+               } else {
+                   rc = fsmUnlink(fsm->path, fsm->mapFlags);
+                   if (!rc) break;
+                   switch (rc) {
+                   case CPIOERR_ENOENT:
+                       if (fsm->fflags & RPMFILE_MISSINGOK)
+                           break;
+                   default:
+                       rpmlog(
+                           (strict_erasures ? RPMLOG_ERR : RPMLOG_DEBUG),
+                               _("%s unlink of %s failed: %s\n"),
+                               rpmteTypeString(te), fsm->path, strerror(errno));
+                       break;
+                   }
+               }
+           }
+           /* XXX Failure to remove is not (yet) cause for failure. */
+           if (!strict_erasures) rc = 0;
 
             if (rc) break;
 
@@ -1945,54 +1985,6 @@ static int fsmStage(FSM_t fsm, fileStage stage)
            free(opath);
        }
 
-       /* Remove erased files. */
-       if (fsm->goal == FSM_PKGERASE) {
-           if (fsm->action == FA_ERASE) {
-               rpmte te = fsmGetTe(fsm);
-               if (S_ISDIR(st->st_mode)) {
-                   rc = fsmRmdir(fsm->path);
-                   if (!rc) break;
-                   switch (rc) {
-                   case CPIOERR_ENOENT: /* XXX rmdir("/") linux 2.2.x kernel hack */
-                   case CPIOERR_ENOTEMPTY:
-       /* XXX make sure that build side permits %missingok on directories. */
-                       if (fsm->fflags & RPMFILE_MISSINGOK)
-                           break;
-
-                       /* XXX common error message. */
-                       rpmlog(
-                           (strict_erasures ? RPMLOG_ERR : RPMLOG_DEBUG),
-                           _("%s rmdir of %s failed: Directory not empty\n"), 
-                               rpmteTypeString(te), fsm->path);
-                       break;
-                   default:
-                       rpmlog(
-                           (strict_erasures ? RPMLOG_ERR : RPMLOG_DEBUG),
-                               _("%s rmdir of %s failed: %s\n"),
-                               rpmteTypeString(te), fsm->path, strerror(errno));
-                       break;
-                   }
-               } else {
-                   rc = fsmUnlink(fsm->path, fsm->mapFlags);
-                   if (!rc) break;
-                   switch (rc) {
-                   case CPIOERR_ENOENT:
-                       if (fsm->fflags & RPMFILE_MISSINGOK)
-                           break;
-                   default:
-                       rpmlog(
-                           (strict_erasures ? RPMLOG_ERR : RPMLOG_DEBUG),
-                               _("%s unlink of %s failed: %s\n"),
-                               rpmteTypeString(te), fsm->path, strerror(errno));
-                       break;
-                   }
-               }
-           }
-           /* XXX Failure to remove is not (yet) cause for failure. */
-           if (!strict_erasures) rc = 0;
-           break;
-       }
-
        /* XXX Special case /dev/log, which shouldn't be packaged anyways */
        if (!S_ISSOCK(st->st_mode) && !IS_DEV_LOG(fsm->path)) {
            /* Rename temporary to final file name. */