build: make Builder.Finish idempotent

This will let it be run as a deferred cleanup operation.

Change-Id: I82175f396e2bd781c287c58ee67eba3c17a8f5b5
diff --git a/build/builder.go b/build/builder.go
index 2eac320..665bfc1 100644
--- a/build/builder.go
+++ b/build/builder.go
@@ -272,7 +272,8 @@
 }
 
 // Finish creates a last shard from the buffered documents, and clears
-// stale shards from previous runs
+// stale shards from previous runs. This should always be called, also
+// in failure cases, to ensure cleanup.
 func (b *Builder) Finish() error {
 	b.flush()
 	b.building.Wait()
@@ -281,6 +282,7 @@
 		for tmp := range b.finishedShards {
 			os.Remove(tmp)
 		}
+		b.finishedShards = map[string]string{}
 		return b.buildError
 	}
 
@@ -289,6 +291,7 @@
 			b.buildError = err
 		}
 	}
+	b.finishedShards = map[string]string{}
 
 	if b.nextShardNum > 0 {
 		b.deleteRemainingShards()