diff --git a/v2/index/index.go b/v2/index/index.go index 96b730f165ba5cbe5c43bde785e762b9407d3da1..669728bbac4fc9cf8122c9375e1b2e0c3249ddba 100644 --- a/v2/index/index.go +++ b/v2/index/index.go @@ -52,9 +52,9 @@ func New(codec multicodec.Code) (Index, error) { } } -// Save writes a generated index into the given `path`. +// Save writes a generated index into the given `path` replacing the file if it exists. func Save(idx Index, path string) error { - stream, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o640) + stream, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o640) if err != nil { return err } diff --git a/v2/testdata/sample-index.carindex b/v2/testdata/sample-index.carindex index 0f91e36507fc21d3a93a00f32bf330e024405af8..5df07d379e444d8fa3a0f5b96a59874f208bd0c1 100644 Binary files a/v2/testdata/sample-index.carindex and b/v2/testdata/sample-index.carindex differ