Better debugging messages
This commit is contained in:
parent
8c374b672a
commit
148d9879d5
11
dir.go
11
dir.go
@ -26,6 +26,7 @@ import (
|
||||
"bazil.org/fuse"
|
||||
"bazil.org/fuse/fs"
|
||||
"golang.org/x/net/context"
|
||||
"log"
|
||||
)
|
||||
|
||||
type versionedDir struct {
|
||||
@ -44,27 +45,31 @@ func newVersionedDir(node *versionedNode, inode uint64) *versionedDir {
|
||||
}
|
||||
|
||||
func (this versionedDir) Attr(attr *fuse.Attr) {
|
||||
log.Printf("versionedDir::Attr: %s", this.node)
|
||||
|
||||
attr.Mode = this.node.info.Mode()
|
||||
attr.Inode = this.inode
|
||||
}
|
||||
|
||||
func (this versionedDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
var entries []fuse.Dirent
|
||||
log.Printf("versionedDir::ReadDirAll: %s", this.node)
|
||||
|
||||
var entries []fuse.Dirent
|
||||
for name, dir := range this.dirs {
|
||||
entry := fuse.Dirent{Inode: dir.inode, Name: name, Type: fuse.DT_File}
|
||||
entries = append(entries, entry)
|
||||
}
|
||||
|
||||
for name, file := range this.files {
|
||||
entry := fuse.Dirent{Inode: file.inode, Name: name, Type: fuse.DT_Dir}
|
||||
entries = append(entries, entry)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func (this versionedDir) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
log.Printf("versionedDir::Lookup: %s", this.node)
|
||||
|
||||
if dir, ok := this.dirs[name]; ok {
|
||||
return dir, nil
|
||||
}
|
||||
|
5
file.go
5
file.go
@ -26,6 +26,7 @@ import (
|
||||
"bazil.org/fuse"
|
||||
"golang.org/x/net/context"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
)
|
||||
|
||||
type versionedFile struct {
|
||||
@ -38,12 +39,16 @@ func newVersionedFile(node *versionedNode, inode uint64) *versionedFile {
|
||||
}
|
||||
|
||||
func (this versionedFile) Attr(attr *fuse.Attr) {
|
||||
log.Printf("versionedFile::Attr: %s", this.node)
|
||||
|
||||
attr.Mode = this.node.info.Mode()
|
||||
attr.Inode = this.inode
|
||||
attr.Size = uint64(this.node.info.Size())
|
||||
}
|
||||
|
||||
func (this versionedFile) ReadAll(ctx context.Context) ([]byte, error) {
|
||||
log.Printf("versionedFile::ReadAll: %s", this.node)
|
||||
|
||||
bytes, err := ioutil.ReadFile(this.node.rebasedPath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -0,0 +1 @@
|
||||
Hello world
|
@ -0,0 +1 @@
|
||||
Blahblahblah
|
9
node.go
9
node.go
@ -22,7 +22,10 @@
|
||||
|
||||
package main
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type versionedNode struct {
|
||||
path string
|
||||
@ -35,3 +38,7 @@ type versionedNodeMap map[string]*versionedNode
|
||||
func (this *versionedNode) rebasedPath() string {
|
||||
return this.ver.rebasePath(this.path)
|
||||
}
|
||||
|
||||
func (this *versionedNode) String() string {
|
||||
return fmt.Sprintf("%s (%s)", this.path, this.rebasedPath())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user