mirror of
https://github.com/rclone/rclone
synced 2024-12-25 17:03:45 +01:00
dlna: count the number of children in the response to BrowseMetadata
This commit is contained in:
parent
ab89e93968
commit
2f10472df3
@ -77,10 +77,17 @@ func (cds *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fi
|
||||
}
|
||||
|
||||
if fileInfo.IsDir() {
|
||||
children, err := cds.readContainer(cdsObject, host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
obj.Class = "object.container.storageFolder"
|
||||
obj.Title = fileInfo.Name()
|
||||
ret = upnpav.Container{Object: obj}
|
||||
return
|
||||
return upnpav.Container{
|
||||
Object: obj,
|
||||
ChildCount: len(children),
|
||||
}, nil
|
||||
}
|
||||
|
||||
if !fileInfo.Mode().IsRegular() {
|
||||
|
@ -3,6 +3,7 @@ package dlna
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"html"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -118,6 +119,9 @@ func TestContentDirectoryBrowseMetadata(t *testing.T) {
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, string(body), "<container ")
|
||||
require.NotContains(t, string(body), "<item ")
|
||||
// expect a <container> element
|
||||
require.Contains(t, string(body), html.EscapeString("<container "))
|
||||
require.NotContains(t, string(body), html.EscapeString("<item "))
|
||||
// with a non-zero childCount
|
||||
require.Contains(t, string(body), html.EscapeString(`childCount="1"`))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user