1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-22 08:25:38 +00:00

Merge pull request #73 from stephen679/tar_cleanup

tar: remove completed TODO's and dead code
This commit is contained in:
Vincent Batts 2016-08-21 16:15:14 -04:00 committed by GitHub
commit 3aa50a7a50

27
tar.go
View file

@ -145,7 +145,6 @@ func (ts *tarStream) readHeaders() {
if hdr.FileInfo().IsDir() && keyword == "size" { if hdr.FileInfo().IsDir() && keyword == "size" {
continue continue
} }
// TODO: handle hardlinks
val, err := keyFunc(hdr.Name, hdr.FileInfo(), tmpFile) val, err := keyFunc(hdr.Name, hdr.FileInfo(), tmpFile)
if err != nil { if err != nil {
ts.setErr(err) ts.setErr(err)
@ -218,13 +217,11 @@ func populateTree(root, e *Entry, hdr *tar.Header) error {
// directory up until the actual file // directory up until the actual file
wd = filepath.Dir(wd) wd = filepath.Dir(wd)
if wd == "." { if wd == "." {
// If file in root directory, no need to traverse down, just append
root.Children = append([]*Entry{e}, root.Children...) root.Children = append([]*Entry{e}, root.Children...)
e.Parent = root e.Parent = root
return nil return nil
} }
} }
// TODO: what about directory/file names with "/" in it?
dirNames := strings.Split(wd, "/") dirNames := strings.Split(wd, "/")
parent := root parent := root
for _, name := range dirNames[:] { for _, name := range dirNames[:] {
@ -422,30 +419,6 @@ func setDifference(this, that []string) []string {
return diff return diff
} }
type relationship int
const (
unknownDir relationship = iota
sameDir
childDir
parentDir
)
func compareDir(curDir, prevDir string) relationship {
curDir = filepath.Clean(curDir)
prevDir = filepath.Clean(prevDir)
if curDir == prevDir {
return sameDir
}
if filepath.Dir(curDir) == prevDir {
return childDir
}
if curDir == filepath.Dir(prevDir) {
return parentDir
}
return unknownDir
}
func (ts *tarStream) setErr(err error) { func (ts *tarStream) setErr(err error) {
ts.err = err ts.err = err
} }