瀏覽代碼

* Don't write the checksum if we aren't writing pack or conf data

svn: 1860
Bryan Drewery 21 年之前
父節點
當前提交
a5475506f6
共有 1 個文件被更改,包括 11 次插入8 次删除
  1. 11 8
      src/binary.c

+ 11 - 8
src/binary.c

@@ -414,14 +414,17 @@ void write_settings(const char *fname, int die, bool conf)
   if (conf)
     bits |= WRITE_CONF;
 
-  if ((hash = bin_checksum(fname, bits, &ctx))) {
-    printf("* Wrote %ssettings to: %s.\n", ((bits & WRITE_PACK) && !(bits & WRITE_CONF)) ? "pack " :
-                                           ((bits & WRITE_CONF) && !(bits & WRITE_PACK)) ? "conf " :
-                                           ((bits & WRITE_PACK) && (bits & WRITE_CONF))  ? "pack/conf "  :
-                                           "",
-                                           fname);
-    if (die == -1)			/* only bother decrypting if we aren't about to exit */
-      edpack(&settings, hash, PACK_DEC);
+  /* only bother writing anything if we have pack or conf, checksum is worthless to write out */
+  if (bits & (WRITE_PACK|WRITE_CONF)) {
+    if ((hash = bin_checksum(fname, bits, &ctx))) {
+      printf("* Wrote %ssettings to: %s.\n", ((bits & WRITE_PACK) && !(bits & WRITE_CONF)) ? "pack " :
+                                             ((bits & WRITE_CONF) && !(bits & WRITE_PACK)) ? "conf " :
+                                             ((bits & WRITE_PACK) && (bits & WRITE_CONF))  ? "pack/conf "  :
+                                             "",
+                                             fname);
+      if (die == -1)			/* only bother decrypting if we aren't about to exit */
+        edpack(&settings, hash, PACK_DEC);
+    }
   }
 
   if (die >= 0)