aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-23 22:12:57 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-23 22:12:57 -0800
commit2f75264ec7928e362f54d0be2453168d21c82834 (patch)
tree95c65f832415013e2bac3ed0b5098fccf561b3b7
parentc936a12afad1632bbc9a3d72b4723ed86da81c33 (diff)
downloadseaweedfs-2f75264ec7928e362f54d0be2453168d21c82834.tar.xz
seaweedfs-2f75264ec7928e362f54d0be2453168d21c82834.zip
mount: avoid use uint64 for greater than zero test
-rw-r--r--weed/filesys/file.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/weed/filesys/file.go b/weed/filesys/file.go
index 5a823f516..c5f75ff4f 100644
--- a/weed/filesys/file.go
+++ b/weed/filesys/file.go
@@ -42,7 +42,7 @@ func (file *File) Attr(ctx context.Context, attr *fuse.Attr) error {
glog.V(4).Infof("file Attr %s, open:%v, existing attr: %+v", file.fullpath(), file.isOpen, attr)
- if file.isOpen <=0 {
+ if file.isOpen <= 0 {
if err := file.maybeLoadEntry(ctx); err != nil {
return err
}
@@ -108,10 +108,11 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
// fmt.Printf("truncate %v \n", fullPath)
var chunks []*filer_pb.FileChunk
for _, chunk := range file.entry.Chunks {
- if uint64(chunk.Offset)+chunk.Size > req.Size {
- chunk.Size = req.Size - uint64(chunk.Offset)
+ int64Size := int64(chunk.Size)
+ if chunk.Offset+int64Size > int64(req.Size) {
+ int64Size = int64(req.Size) - chunk.Offset
}
- if chunk.Size > 0 {
+ if int64Size > 0 {
chunks = append(chunks, chunk)
}
}
@@ -218,7 +219,7 @@ func (file *File) Forget() {
}
func (file *File) maybeLoadEntry(ctx context.Context) error {
- if file.entry == nil || file.isOpen <= 0{
+ if file.entry == nil || file.isOpen <= 0 {
entry, err := file.wfs.maybeLoadEntry(ctx, file.dir.Path, file.Name)
if err != nil {
return err