From 7e2568a3125b3a3cb25a395439cbb6cee7e5e76a Mon Sep 17 00:00:00 2001 From: Dan Walters Date: Mon, 17 Feb 2020 19:13:17 -0500 Subject: [PATCH] dlna: cds: don't specify childCount at all when unknown Basically, solving #3541 with a different approach - bringing in the upstream upnpav module, and changing ChildCount from int to a *int to avoid childCount="0" in the XML output when that value is simply unknown. Current approach is leading to some recursion issues and according to the DLNA spec it shouldn't be necessary, anyway. --- cmd/serve/dlna/cds.go | 10 ++---- cmd/serve/dlna/dlna_test.go | 4 +-- cmd/serve/dlna/upnpav/upnpav.go | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 cmd/serve/dlna/upnpav/upnpav.go diff --git a/cmd/serve/dlna/cds.go b/cmd/serve/dlna/cds.go index 5a30455a1..1fa1cfe9f 100644 --- a/cmd/serve/dlna/cds.go +++ b/cmd/serve/dlna/cds.go @@ -16,8 +16,8 @@ import ( "github.com/anacrolix/dms/dlna" "github.com/anacrolix/dms/upnp" - "github.com/anacrolix/dms/upnpav" "github.com/pkg/errors" + "github.com/rclone/rclone/cmd/serve/dlna/upnpav" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/vfs" ) @@ -77,16 +77,10 @@ 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() return upnpav.Container{ - Object: obj, - ChildCount: len(children), + Object: obj, }, nil } diff --git a/cmd/serve/dlna/dlna_test.go b/cmd/serve/dlna/dlna_test.go index cca76d877..eaeab4091 100644 --- a/cmd/serve/dlna/dlna_test.go +++ b/cmd/serve/dlna/dlna_test.go @@ -122,8 +122,8 @@ func TestContentDirectoryBrowseMetadata(t *testing.T) { // expect a element require.Contains(t, string(body), html.EscapeString("