Cleanup
This commit is contained in:
parent
0613779a78
commit
e512bd689e
@ -32,11 +32,12 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
var inodeCnt uint64
|
||||
//
|
||||
// database
|
||||
//
|
||||
|
||||
type database struct {
|
||||
base string
|
||||
@ -175,7 +176,3 @@ func (this *database) parseVerName(name string) (time.Time, error) {
|
||||
|
||||
return time.Unix(timestamp, 0), nil
|
||||
}
|
||||
|
||||
func allocInode() uint64 {
|
||||
return atomic.AddUint64(&inodeCnt, 1)
|
||||
}
|
||||
|
4
dir.go
4
dir.go
@ -30,6 +30,10 @@ import (
|
||||
"path"
|
||||
)
|
||||
|
||||
//
|
||||
// versionedDir
|
||||
//
|
||||
|
||||
type versionedDir struct {
|
||||
dirs map[string]*versionedDir
|
||||
files map[string]*versionedFile
|
||||
|
4
file.go
4
file.go
@ -30,6 +30,10 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
//
|
||||
// versionedFile
|
||||
//
|
||||
|
||||
type versionedFile struct {
|
||||
node *versionedNode
|
||||
inode uint64
|
||||
|
4
meta.go
4
meta.go
@ -29,6 +29,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
//
|
||||
// versionMetadata
|
||||
//
|
||||
|
||||
type versionMetadata struct {
|
||||
Deleted []string `json:"deleted"`
|
||||
path string
|
||||
|
17
node.go
17
node.go
@ -24,12 +24,15 @@ package main
|
||||
|
||||
import (
|
||||
"bazil.org/fuse"
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
//
|
||||
// versionedNode
|
||||
//
|
||||
|
||||
type versionedNode struct {
|
||||
path string
|
||||
info os.FileInfo
|
||||
@ -110,6 +113,14 @@ func (this *versionedNode) rebasedPath() string {
|
||||
return this.ver.rebasePath(this.path)
|
||||
}
|
||||
|
||||
func (this *versionedNode) rebasedTermPath() string {
|
||||
if this.ver.terminus == nil {
|
||||
return this.rebasedPath()
|
||||
}
|
||||
|
||||
return this.ver.terminus.rebasePath(this.path)
|
||||
}
|
||||
|
||||
func (this *versionedNode) owner() (gid, uid uint32) {
|
||||
stat := this.info.Sys().(*syscall.Stat_t)
|
||||
|
||||
@ -138,7 +149,3 @@ func (this *versionedNode) attr(attr *fuse.Attr) {
|
||||
attr.Gid, attr.Uid = this.owner()
|
||||
attr.Rdev = uint32(stat.Rdev)
|
||||
}
|
||||
|
||||
func (this *versionedNode) String() string {
|
||||
return fmt.Sprintf("%s (%s)", this.path, this.rebasedPath())
|
||||
}
|
||||
|
35
util.go
Normal file
35
util.go
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
|
||||
* Author: Alex Yatskov <alex@foosoft.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import "sync/atomic"
|
||||
|
||||
//
|
||||
// utilities
|
||||
//
|
||||
|
||||
var inodeCnt uint64
|
||||
|
||||
func allocInode() uint64 {
|
||||
return atomic.AddUint64(&inodeCnt, 1)
|
||||
}
|
12
version.go
12
version.go
@ -32,6 +32,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
//
|
||||
// version
|
||||
//
|
||||
|
||||
type version struct {
|
||||
base string
|
||||
parent *version
|
||||
@ -141,10 +145,6 @@ func (this *version) rebasePath(paths ...string) string {
|
||||
return filepath.Join(combined...)
|
||||
}
|
||||
|
||||
func (this *version) Root() (fs.Node, error) {
|
||||
return this.root, nil
|
||||
}
|
||||
|
||||
func (this *version) dump(root *versionedDir, depth int) {
|
||||
indent := strings.Repeat("\t", depth)
|
||||
for name, dir := range root.dirs {
|
||||
@ -159,3 +159,7 @@ func (this *version) dump(root *versionedDir, depth int) {
|
||||
func (this *version) dumpRoot() {
|
||||
this.dump(this.root, 0)
|
||||
}
|
||||
|
||||
func (this *version) Root() (fs.Node, error) {
|
||||
return this.root, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user