Closed marky1991 closed 10 years ago
Aha! After waiting a long time, nothing happened. After doing a search, however, the letters suddenly returned. After doing another restart of the server, the letters were gone again. After another search, they came back.
Alright! If you switch back to Browse after searching, are the letters gone again?
No, after searching, they stay until the next server restart.
Well, that is some mysterious :shit: going on there.
So, these are all the places where we cut strings. We can check them one after another and ✓ them...
[cherrymusic]$ grep -PRn "\[\d:" ./cherrymusicserver/*
I've discovered the issue.
The root cause was that in my config file, I specified my basepath like this:
basedir = /home/mark/Música/
, with a trailing slash. Looking at the comments in the configuration file, this is indeed not exactly as specified. (But the difference is so tiny that I as a user (or a developer, on that note) would never expect this to cause an issue.)
In cherrymodel.py, strippath does this:
if path.startswith(cherry.config['media.basedir']):
return path[len(cherry.config['media.basedir']) + 1:]
which assumes that media.basedir doesn't have a trailing slash. If there is a trailing slash, it removes the first character from the rest of the path, giving the faulty behavior I noticed. (How it ends up working after doing a search, I don't know. I didn't bother further looking into the code.)
I'm feeling too lazy to bother forking the project for one little fix, but if I were going to fix the code, I'd do something like this:
def strippath(path):
if path.startswith(cherry.config['media.basedir']):
return os.path.relpath(path, cherry.config['media.basedir'])
return path
With this modification, everything works properly with or without the trailing slash. (I've verified that this function is available for all the versions of python that y'all support.)
As far as I can tell, no other code uses the limiting assumption, so this should be the only trouble spot.
Thanks for your investigation and you fix! I've commited the fix to the devel branch.
Have a few funny icons as reward! :dancers: :octopus: :8ball: :monkey:
Good job tracking that one down. I like the use of relpath
there, very neat.
Relevant info from previous ticket:
Interestingly, now my folders are missing the first character, e.g. from the logs: (If this is not related to this fix, let me know and I'll move this to a seperate ticket)
As a result of that, I can't play view files through "Browse Files" anymore. From the logs:
I'm reliably getting this error. It appears to somehow go away a while after the server is restarted.
Still trying to figure out what makes it start working properly.