Commit 64bb51b2 authored by Masih H. Derkani's avatar Masih H. Derkani Committed by Masih H. Derkani

Replace a file if exists on `index.Save`

If appendage is needed there is already `car.AttachIndex`.
parent aa62719d
......@@ -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
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment