mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 11:55:01 +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() {
|
if fileInfo.IsDir() {
|
||||||
|
children, err := cds.readContainer(cdsObject, host)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
obj.Class = "object.container.storageFolder"
|
obj.Class = "object.container.storageFolder"
|
||||||
obj.Title = fileInfo.Name()
|
obj.Title = fileInfo.Name()
|
||||||
ret = upnpav.Container{Object: obj}
|
return upnpav.Container{
|
||||||
return
|
Object: obj,
|
||||||
|
ChildCount: len(children),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fileInfo.Mode().IsRegular() {
|
if !fileInfo.Mode().IsRegular() {
|
||||||
|
@ -3,6 +3,7 @@ package dlna
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -118,6 +119,9 @@ func TestContentDirectoryBrowseMetadata(t *testing.T) {
|
|||||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Contains(t, string(body), "<container ")
|
// expect a <container> element
|
||||||
require.NotContains(t, string(body), "<item ")
|
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