diff --git a/dlna/dms/cds.go b/dlna/dms/cds.go index 3d83554..bbf2a69 100644 --- a/dlna/dms/cds.go +++ b/dlna/dms/cds.go @@ -157,7 +157,11 @@ func (me *contentDirectoryService) cdsObjectDynamicStreamToUpnpavObject(cdsObjec // Turns the given entry and DMS host into a UPnP object. A nil object is // returned if the entry is not of interest. -func (me *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fileInfo os.FileInfo, host, userAgent string) (ret interface{}, err error) { +func (me *contentDirectoryService) cdsObjectToUpnpavObject( + cdsObject object, + fileInfo os.FileInfo, + host, userAgent string, +) (ret interface{}, err error) { entryFilePath := cdsObject.FilePath() ignored, err := me.IgnorePath(entryFilePath) if err != nil { @@ -179,7 +183,10 @@ func (me *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fil if fileInfo.IsDir() { obj.Class = "object.container.storageFolder" obj.Title = fileInfo.Name() - ret = upnpav.Container{Object: obj, ChildCount: me.objectChildCount(cdsObject)} + childCount := me.objectChildCount(cdsObject) + if childCount != 0 { + ret = upnpav.Container{Object: obj, ChildCount: childCount} + } return } if !fileInfo.Mode().IsRegular() { @@ -306,7 +313,10 @@ func (me *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fil } // Returns all the upnpav objects in a directory. -func (me *contentDirectoryService) readContainer(o object, host, userAgent string) (ret []interface{}, err error) { +func (me *contentDirectoryService) readContainer( + o object, + host, userAgent string, +) (ret []interface{}, err error) { sfis := sortableFileInfoSlice{ // TODO(anacrolix): Dig up why this special cast was added. FoldersLast: strings.Contains(userAgent, `AwoX/1.1`), @@ -442,7 +452,11 @@ func (me *contentDirectoryService) Handle(action string, argsXML []byte, r *http {"UpdateID", me.updateIDString()}, }, nil default: - return nil, upnp.Errorf(upnp.ArgumentValueInvalidErrorCode, "unhandled browse flag: %v", browse.BrowseFlag) + return nil, upnp.Errorf( + upnp.ArgumentValueInvalidErrorCode, + "unhandled browse flag: %v", + browse.BrowseFlag, + ) } case "GetSearchCapabilities": return [][2]string{