mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
truncate file content during creating
This commit is contained in:
parent
7283d68e32
commit
e6e85a6b2c
|
@ -370,12 +370,12 @@ func (v *Volume) copyDataAndGenerateIndexFile(dstName, idxName string) (err erro
|
||||||
var (
|
var (
|
||||||
dst, idx *os.File
|
dst, idx *os.File
|
||||||
)
|
)
|
||||||
if dst, err = os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE, 0644); err != nil {
|
if dst, err = os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer dst.Close()
|
defer dst.Close()
|
||||||
|
|
||||||
if idx, err = os.OpenFile(idxName, os.O_WRONLY|os.O_CREATE, 0644); err != nil {
|
if idx, err = os.OpenFile(idxName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer idx.Close()
|
defer idx.Close()
|
||||||
|
|
|
@ -37,7 +37,7 @@ func runFix(cmd *Command, args []string) bool {
|
||||||
if *fixVolumeCollection != "" {
|
if *fixVolumeCollection != "" {
|
||||||
fileName = *fixVolumeCollection + "_" + fileName
|
fileName = *fixVolumeCollection + "_" + fileName
|
||||||
}
|
}
|
||||||
indexFile, err := os.OpenFile(path.Join(*fixVolumePath, fileName+".idx"), os.O_WRONLY|os.O_CREATE, 0644)
|
indexFile, err := os.OpenFile(path.Join(*fixVolumePath, fileName+".idx"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Create Volume Index [ERROR] %s\n", err)
|
glog.Fatalf("Create Volume Index [ERROR] %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue