Skip to content

Commit

Permalink
Don't show empty dirs
Browse files Browse the repository at this point in the history
VLC seems to pick through them asking about each and every one individually.
  • Loading branch information
anacrolix committed Nov 9, 2023
1 parent fe4b7cf commit 9461df6
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions dlna/dms/cds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
Expand Down Expand Up @@ -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`),
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 9461df6

Please sign in to comment.