Use nil storage.ID for empty directories, emit in JSON

This commit is contained in:
Alexander Neumann 2014-04-21 23:30:00 +02:00
parent 4f3a54dc40
commit 0061207558
2 changed files with 6 additions and 1 deletions

View file

@ -18,7 +18,7 @@ type Node struct {
ModTime time.Time `json:"mtime"`
User uint32 `json:"user"`
Group uint32 `json:"group"`
Content ID `json:"content"`
Content ID `json:"content,omitempty"`
}
func NewTree() *Tree {

View file

@ -36,6 +36,11 @@ func archive_dir(repo storage.Repository, path string) (storage.ID, error) {
return nil, err
}
// use nil ID for empty directories
if len(entries) == 0 {
return nil, nil
}
t := storage.NewTree()
for _, e := range entries {
node := storage.NodeFromFileInfo(e)