Skip to content

Commit

Permalink
add lint test step
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadVatandoost committed Aug 11, 2021
1 parent 26b4876 commit 9c4bb04
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
- name: list-test
run: make lint-test
- name: unit-test
run: make unit-test
Expand Down
2 changes: 1 addition & 1 deletion IO.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (fse *FSEngine) ReadBlock(blockIndex uint32, fileID uint32) ([]byte, error)

var err error
buf := make([]byte, fse.blockSize)
n, err := fse.file.ReadAt(buf, int64(blockIndex*fse.blockSize))
n, err := fse.file.ReadAt(buf, int64(blockIndex)*int64(fse.blockSize))
if err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/Header/IO.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func (hfs *HFileSystem) Close() error {
}

// ToDo:update file system
//err = hfs.file.Sync()
//if err != nil {
// hfs.log.Warnv("Can not sync file", "err", err.Error())
// // ToDo: remove it
// return err
//}
err = hfs.file.Sync()
if err != nil {
hfs.log.Warnv("Can not sync file", "err", err.Error())
// ToDo: remove it
return err
}

return nil
}
Expand Down
19 changes: 9 additions & 10 deletions internal/Header/fileIndex.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package Header_

import (
"fmt"
"hash/crc32"

"github.com/fanap-infra/fsEngine/pkg/fileIndex"
)
Expand Down Expand Up @@ -32,22 +31,22 @@ func (hfs *HFileSystem) updateFileIndex() error {
if err != nil {
return err
}
hfs.fileIndexSize = uint32(len(fi))
checkSum := crc32.ChecksumIEEE(fi)
if hfs.fiChecksum == checkSum {
return nil
if len(fi) > FileIndexMaxByteSize {
return fmt.Errorf("fileIndex size %v is too large, Max valid size: %v",
len(fi), FileIndexMaxByteSize)
}
hfs.fiChecksum = checkSum
hfs.fileIndexSize = uint32(len(fi))
//checkSum := crc32.ChecksumIEEE(fi)
//if hfs.fiChecksum == checkSum {
// return nil
//}
//hfs.fiChecksum = checkSum

if hfs.fileIndexSize == 0 {
hfs.log.Warn("file indexes size is zero")
// return fmt.Errorf("fileIndex size %v is Zero",
// hfs.fileIndexSize)
}
if hfs.fileIndexSize > FileIndexMaxByteSize {
return fmt.Errorf("fileIndex size %v is too large, Max valid size: %v",
hfs.fileIndexSize, FileIndexMaxByteSize)
}

// n, err := hfs.file.WriteAt(fi, FileIndexByteIndex)
n, err := hfs.writeAt(fi, HeaderBlockIndex)
Expand Down
16 changes: 8 additions & 8 deletions internal/Header/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type HFileSystem struct {
blmSize uint32
path string
log *log.Logger
fiChecksum uint32
mu sync.Mutex
conf configs
eventHandler blockAllocationMap.Events
// fiChecksum uint32
mu sync.Mutex
conf configs
eventHandler blockAllocationMap.Events
}

func (hfs *HFileSystem) UpdateFSHeader() error {
Expand All @@ -53,10 +53,10 @@ func (hfs *HFileSystem) UpdateFSHeader() error {
return err
}

//err = hfs.file.Sync()
//if err != nil {
// hfs.log.Warnv("Can not sync file", "err", err.Error())
//}
err = hfs.file.Sync()
if err != nil {
hfs.log.Warnv("Can not sync file", "err", err.Error())
}

//err = hfs.updateHash()
//if err != nil {
Expand Down

0 comments on commit 9c4bb04

Please sign in to comment.