Skip to content

Commit

Permalink
query: fix default value type for fs paths. Fixes #2142
Browse files Browse the repository at this point in the history
  • Loading branch information
lazka committed Dec 17, 2016
1 parent 60a2f00 commit 47d50be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions quodlibet/quodlibet/query/_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,13 @@ def __init__(self, names, res):
self._names.append(name)

def search(self, data):
fs_default = fsnative()

for name in self._names:
val = data.get(name)
if val is None:
if name in ("filename", "mountpoint"):
val = fsn2text(data.get("~" + name, fsnative()))
val = fsn2text(data.get("~" + name, fs_default))
else:
val = data.get("~" + name, "")

Expand All @@ -487,7 +489,7 @@ def search(self, data):
return True

for name in self.__fs:
if self.res.search(fsn2text(data(name))):
if self.res.search(fsn2text(data(name, fs_default))):
return True

return False
Expand Down
4 changes: 4 additions & 0 deletions quodlibet/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ def test_mountpoint_utf8_fallback(self):
self.failUnless(Query(u"mountpoint=foü").search(self.s3))
self.failUnless(Query(u"mountpoint=öä").search(self.s3))

def test_mountpoint_no_value(self):
af = AudioFile({"~filename": fsnative(u"foo")})
assert not Query(u"~mountpoint=bla").search(af)

def test_star_numeric(self):
self.assertRaises(ValueError, Query, u"foobar", star=["~#mtime"])

Expand Down

0 comments on commit 47d50be

Please sign in to comment.