add missing link cleanup subcommand.

This commit is contained in:
sm
2016-07-09 21:40:14 -07:00
parent ceb4206787
commit 1abff34b3d
4 changed files with 118 additions and 2 deletions
+6 -1
View File
@@ -25,7 +25,7 @@ func (m Media) Move(root string) error {
}
defer f.Close()
content := filepath.Join(root, "content", m.Hash[:2], m.Hash[2:]+m.Extension)
content := m.Content(root)
if _, err := os.Stat(content); !os.IsNotExist(err) {
return Dup{content}
@@ -67,3 +67,8 @@ func (m Media) Move(root string) error {
// return os.Symlink(rel, name)
return os.Link(content, name)
}
// Content returns the content-address path starting at root.
func (m Media) Content(root string) string {
return filepath.Join(root, "content", m.Hash[:2], m.Hash[2:]+m.Extension)
}