Browse Source

adjust NewDiskFile() paramaters

pull/1115/head
Chris Lu 5 years ago
parent
commit
4b5ba4927f
  1. 2
      unmaintained/change_superblock/change_superblock.go
  2. 2
      unmaintained/fix_dat/fix_dat.go
  3. 2
      unmaintained/remove_duplicate_fids/remove_duplicate_fids.go
  4. 4
      weed/storage/backend/disk_file.go
  5. 2
      weed/storage/needle/needle_read_write_test.go
  6. 2
      weed/storage/volume_loading.go
  7. 2
      weed/storage/volume_super_block.go
  8. 8
      weed/storage/volume_vacuum.go

2
unmaintained/change_superblock/change_superblock.go

@ -48,7 +48,7 @@ func main() {
if err != nil {
glog.Fatalf("Open Volume Data File [ERROR]: %v", err)
}
datBackend := backend.NewDiskFile(*fixVolumePath, datFile)
datBackend := backend.NewDiskFile(datFile)
defer datBackend.Close()
superBlock, err := storage.ReadSuperBlock(datBackend)

2
unmaintained/fix_dat/fix_dat.go

@ -50,7 +50,7 @@ func main() {
if err != nil {
glog.Fatalf("Read Volume Data %v", err)
}
datBackend := backend.NewDiskFile(datFileName, datFile)
datBackend := backend.NewDiskFile(datFile)
defer datBackend.Close()
newDatFile, err := os.Create(path.Join(*fixVolumePath, fileName+".dat_fixed"))

2
unmaintained/remove_duplicate_fids/remove_duplicate_fids.go

@ -50,7 +50,7 @@ func (scanner *VolumeFileScanner4SeeDat) VisitNeedle(n *needle.Needle, offset in
if err != nil {
glog.Fatalf("Write New Volume Data %v", err)
}
scanner.datBackend = backend.NewDiskFile(newFileName, newDatFile)
scanner.datBackend = backend.NewDiskFile(newDatFile)
scanner.datBackend.WriteAt(scanner.block.Bytes(), 0)
}

4
weed/storage/backend/disk_file.go

@ -14,9 +14,9 @@ type DiskFile struct {
fullFilePath string
}
func NewDiskFile(fullFilePath string, f *os.File) *DiskFile {
func NewDiskFile(f *os.File) *DiskFile {
return &DiskFile{
fullFilePath: fullFilePath,
fullFilePath: f.Name(),
File: f,
}
}

2
weed/storage/needle/needle_read_write_test.go

@ -55,7 +55,7 @@ func TestAppend(t *testing.T) {
os.Remove(tempFile.Name())
}()
datBackend := backend.NewDiskFile(tempFile.Name(), tempFile)
datBackend := backend.NewDiskFile(tempFile)
defer datBackend.Close()
offset, _, _, _ := n.Append(datBackend, CurrentVersion)

2
weed/storage/volume_loading.go

@ -50,7 +50,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
return fmt.Errorf("Volume Data file %s.dat does not exist.", fileName)
}
}
v.DataBackend = backend.NewDiskFile(fileName+".dat", dataFile)
v.DataBackend = backend.NewDiskFile(dataFile)
if e != nil {
if !os.IsPermission(e) {

2
weed/storage/volume_super_block.go

@ -98,7 +98,7 @@ func (v *Volume) maybeWriteSuperBlock() error {
//read-only, but zero length - recreate it!
var dataFile *os.File
if dataFile, e = os.Create(v.DataBackend.String()); e == nil {
v.DataBackend = backend.NewDiskFile(v.DataBackend.String(), dataFile)
v.DataBackend = backend.NewDiskFile(dataFile)
if _, e = v.DataBackend.WriteAt(v.SuperBlock.Bytes(), 0); e == nil {
v.readOnly = false
}

8
weed/storage/volume_vacuum.go

@ -147,7 +147,7 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
defer oldIdxFile.Close()
oldDatFile, err := os.Open(oldDatFileName)
oldDatBackend := backend.NewDiskFile(oldDatFileName, oldDatFile)
oldDatBackend := backend.NewDiskFile(oldDatFile)
defer oldDatBackend.Close()
if indexSize, err = verifyIndexFileIntegrity(oldIdxFile); err != nil {
@ -198,7 +198,7 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
if dst, err = os.OpenFile(newDatFileName, os.O_RDWR, 0644); err != nil {
return fmt.Errorf("open dat file %s failed: %v", newDatFileName, err)
}
dstDatBackend := backend.NewDiskFile(newDatFileName, dst)
dstDatBackend := backend.NewDiskFile(dst)
defer dstDatBackend.Close()
if idx, err = os.OpenFile(newIdxFileName, os.O_RDWR, 0644); err != nil {
@ -328,7 +328,7 @@ func (v *Volume) copyDataAndGenerateIndexFile(dstName, idxName string, prealloca
v: v,
now: uint64(time.Now().Unix()),
nm: NewBtreeNeedleMap(idx),
dstBackend: backend.NewDiskFile(dstName, dst),
dstBackend: backend.NewDiskFile(dst),
writeThrottler: util.NewWriteThrottler(compactionBytePerSecond),
}
err = ScanVolumeFile(v.dir, v.Collection, v.Id, v.needleMapKind, scanner)
@ -342,7 +342,7 @@ func (v *Volume) copyDataBasedOnIndexFile(dstName, idxName string) (err error) {
if dst, err = os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
return
}
dstDatBackend := backend.NewDiskFile(dstName, dst)
dstDatBackend := backend.NewDiskFile(dst)
defer dstDatBackend.Close()
if idx, err = os.OpenFile(idxName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {

Loading…
Cancel
Save