]> mj.ucw.cz Git - libucw.git/blobdiff - lib/bucket.c
Added a library module for generation of cryptographically secure
[libucw.git] / lib / bucket.c
index 626c87ac642dd029d5d12b4c84846d77759c8557..e35f99f8cc011805f6a000ad724eeb3aa6a07ff4 100644 (file)
@@ -349,27 +349,29 @@ obuck_shakedown(int (*kibitz)(struct obuck_header *old, oid_t new, byte *buck))
        goto reread;
       if (GET_U32(rbuf + roff + l - 4) != OBUCK_TRAILER)
        obuck_broken("missing trailer during shakedown");
-      if (rhdr->oid != OBUCK_OID_DELETED &&
-         kibitz(rhdr, w_bucket_start >> OBUCK_SHIFT, (byte *)(rhdr+1)))
+      if (rhdr->oid != OBUCK_OID_DELETED)
        {
-         if (bucket_start == w_bucket_start)
+         if (kibitz(rhdr, w_bucket_start >> OBUCK_SHIFT, (byte *)(rhdr+1)))
            {
-             /* No copying needed now nor ever in the past, hence woff==0 */
-             wstart += l;
-           }
-         else
-           {
-             if (obuck_shake_buflen - woff < l)
+             if (bucket_start == w_bucket_start)
+               {
+                 /* No copying needed now nor ever in the past, hence woff==0 */
+                 wstart += l;
+               }
+             else
                {
-                 if (sh_pwrite(obuck_fd, wbuf, woff, wstart) != woff)
-                   die("obuck_shakedown write failed: %m");
-                 wstart += woff;
-                 woff = 0;
+                 if (obuck_shake_buflen - woff < l)
+                   {
+                     if (sh_pwrite(obuck_fd, wbuf, woff, wstart) != woff)
+                       die("obuck_shakedown write failed: %m");
+                     wstart += woff;
+                     woff = 0;
+                   }
+                 whdr = (struct obuck_header *)(wbuf+woff);
+                 memcpy(whdr, rhdr, l);
+                 whdr->oid = w_bucket_start >> OBUCK_SHIFT;
+                 woff += l;
                }
-             whdr = (struct obuck_header *)(wbuf+woff);
-             memcpy(whdr, rhdr, l);
-             whdr->oid = w_bucket_start >> OBUCK_SHIFT;
-             woff += l;
            }
        }
       else