Reset abort request flag on retry.
authorJán Kupec <jkupec@suse.cz>
Thu, 28 Jan 2010 18:01:29 +0000 (19:01 +0100)
committerJán Kupec <jkupec@suse.cz>
Thu, 28 Jan 2010 18:01:29 +0000 (19:01 +0100)
- also watch the flag in download progress handler

src/Zypper.h
src/callbacks/media.cc
src/callbacks/media.h

index 39d361d..fdfc7cb 100644 (file)
@@ -183,7 +183,7 @@ public:
   bool runningShell() const { return _running_shell; }
   bool runningHelp() const { return _running_help; }
   bool exitRequested() const { return _exit_requested; }
-  void requestExit() { _exit_requested = true; }
+  void requestExit(bool do_exit = true) { _exit_requested = do_exit; }
 
   int argc() { return _running_shell ? _sh_argc : _argc; }
   char ** argv() { return _running_shell ? _sh_argv : _argv; }
index b7a41ee..2188fb7 100644 (file)
@@ -215,18 +215,27 @@ ZmartRecipients::MediaChangeReportReceiver::requestMedia(
         _("Please insert medium [%s] #%d and type 'y' to continue or 'n' to cancel the operation."))
         % label % mediumNr);
     if (read_bool_answer(PROMPT_YN_MEDIA_CHANGE, request, false))
+    {
+      zypper.requestExit(false);
       return MediaChangeReport::RETRY;
+    }
     else
       return MediaChangeReport::ABORT;
   }
 
   if (error == MediaChangeReport::IO_SOFT)
   {
-    MediaChangeReport::Action action = MediaChangeReport::RETRY;
+    MediaChangeReport::Action default_action = MediaChangeReport::RETRY;
     if (repeat_counter.counter_overrun(url))
-      action = MediaChangeReport::ABORT;
-    return (Action) read_action_ari_with_timeout(PROMPT_ARI_MEDIA_PROBLEM,
-      30,action);
+      default_action = MediaChangeReport::ABORT;
+
+    MediaChangeReport::Action action = (Action) read_action_ari_with_timeout(
+        PROMPT_ARI_MEDIA_PROBLEM, 30, default_action);
+
+    if (action == MediaChangeReport::RETRY)
+      zypper.requestExit(false);
+
+    return action;
   }
 
   Action action = MediaChangeReport::ABORT;
@@ -256,5 +265,8 @@ ZmartRecipients::MediaChangeReportReceiver::requestMedia(
       && !zypper.runtimeData().seen_verify_hint)
     print_verify_hint(Zypper::instance()->out());
 
+  if (action == MediaChangeReport::RETRY)
+    zypper.requestExit(false);
+
   return action;
 }
index b3a439f..26028f1 100644 (file)
@@ -110,6 +110,13 @@ namespace ZmartRecipients
         return true;
 
       Zypper & zypper = *(Zypper::instance());
+
+      if (zypper.exitRequested())
+      {
+        DBG << "received exit request" << std::endl;
+        return false;
+      }
+
       if (!zypper.runtimeData().raw_refresh_progress_label.empty())
         zypper.out().progress(
           "raw-refresh", zypper.runtimeData().raw_refresh_progress_label);
@@ -122,7 +129,6 @@ namespace ZmartRecipients
       return true;
     }
 
-    // not used anywhere in libzypp 3.20.0 (really)
     virtual DownloadProgressReport::Action
     problem( const zypp::Url & uri, DownloadProgressReport::Error error, const std::string & description )
     {
@@ -131,7 +137,11 @@ namespace ZmartRecipients
         Zypper::instance()->out().dwnldProgressEnd(uri, _last_drate_avg, true);
       Zypper::instance()->out().error(zcb_error2str(error, description));
 
-      return (Action) read_action_ari(PROMPT_ARI_MEDIA_PROBLEM, DownloadProgressReport::ABORT);
+      Action action = (Action) read_action_ari(
+          PROMPT_ARI_MEDIA_PROBLEM, DownloadProgressReport::ABORT);
+      if (action == DownloadProgressReport::RETRY)
+        Zypper::instance()->requestExit(false);
+      return action;
     }
 
     // used only to finish, errors will be reported in media change callback (libzypp 3.20.0)