mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
35 lines
735 B
Go
35 lines
735 B
Go
|
package filesys
|
||
|
|
||
|
import (
|
||
|
"bazil.org/fuse"
|
||
|
"fmt"
|
||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||
|
"context"
|
||
|
)
|
||
|
|
||
|
type File struct {
|
||
|
FileId filer.FileId
|
||
|
Name string
|
||
|
wfs *WFS
|
||
|
}
|
||
|
|
||
|
func (file *File) Attr(context context.Context, attr *fuse.Attr) error {
|
||
|
attr.Mode = 0444
|
||
|
ret, err := filer.GetFileSize(file.wfs.filer, string(file.FileId))
|
||
|
if err == nil {
|
||
|
attr.Size = ret.Size
|
||
|
} else {
|
||
|
fmt.Printf("Get file %s attr [ERROR] %s\n", file.Name, err)
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (file *File) ReadAll(ctx context.Context) ([]byte, error) {
|
||
|
ret, err := filer.GetFileContent(file.wfs.filer, string(file.FileId))
|
||
|
if err == nil {
|
||
|
return ret.Content, nil
|
||
|
}
|
||
|
fmt.Printf("Get file %s content [ERROR] %s\n", file.Name, err)
|
||
|
return nil, err
|
||
|
}
|