chiark / gitweb /
otter(1) reset: Bundle scanning: Improve messages and style
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 May 2021 13:03:01 +0000 (14:03 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 May 2021 13:03:34 +0000 (14:03 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/otter.rs

index 76b398cd2ee5e860fde319b9735d85a165bf82b5..3f2430f4011ecec7724ab56960931fba0df7be3f 100644 (file)
@@ -802,10 +802,16 @@ mod reset_game {
         use EitherOrBoth::*;
         use bundles::State::*;
         match eob {
-          Left(local) => Err(format!("server is missing {}", local.file)),
-          Right(_) => Ok(()),
-          Both(_local, (id, Uploading))
-            => Err(format!("server has incomplete upload :{}", id)),
+          Right(_) => {
+            Ok(())
+          },
+          Left(local) => {
+            Err(format!("server is missing {} {} {}",
+                        local.kind, local.hash, local.file))
+          },
+          Both(_local, (id, Uploading)) => {
+            Err(format!("server has incomplete upload :{}", id))
+          },
           Both(local, (id, Loaded(remote))) => {
             if (local.size,  local.hash) !=
                (remote.size, remote.hash) {
@@ -815,11 +821,11 @@ mod reset_game {
             }
           }
         }
-      }).find_map(Result::err) {
-        None => {
+      }).find_map(Result::err).map_or_else(|| Ok(()), Err) {
+        Ok(()) => {
           eprintln!("Reusing server's existing bundles");
         },
-        Some(why) => {
+        Err(why) => {
           if ma.verbose >= 0 {
             eprintln!("Re-uploading bundles: {}", why);
           }