Closed aagon closed 1 year ago
Update : the missing trailing slash in the aforementioned PROPFIND request is confirmed to be the cause of the very long update time.
A simple server-side workaround is to rewrite the request before serving it. For instance, in lighttpd
:
webdav.activate = "enable"
webdav.is-readonly = "enable"
dir-listing.activate = "enable"
url.rewrite-if-not-file = ( "^(.*[^/])$" => "$1/" )
When the server is setup like this, the malformed PROPFIND requests are corrected and dealt with correctly almost immediately, resulting in very reduced update times.
Note that it is very important that the adding of the trailing slash is made only on collections, NOT on regular files, using conditional rules like url.rewrite-if-not-file
(or the nginx
or apache
equivalent). This is because mpd
interprets a trailing slash as evidence a file is a collection and needs to be treated as such (by issuing a new PROPFIND request of depth 1 on it, to find its contents). As a side remark, maybe it would be better to rather use either the getcontenttype
or the resourcetype
property, since mpd
requests it anyway and the WEBDAV standards stipulates they MUST be provided. Generally speaking, a trailing slash on a URL or href does not mean at all that a file is a directory.
Naturally, this is not particularly satisfying, as correction should be guaranteed on the client side as well. The offending line has been found, a PR will be added shortly, discussion will move there.
Obviously, your WebDAV server is buggy if it generates an empty "200" response and takes so long to generate it. MPD doesn't support buggy WebDAV servers.
I admit, the server should be able to handle collection names without the trailing slash correctly, and as I've said, it only takes for a specific setting to make it work correctly. The empty 200 response is a lighttpd
bug, I agree.
That being said, the WebDAV standard RFC (https://www.rfc-editor.org/rfc/rfc4918) also states :
In general, clients SHOULD use the trailing slash form of collection names.
Which mpd clearly does not.
SHOULD is not an obligation in RFC parlance.
Still, the ideal situation, from a broad standards-compliance point of view, would be for mpd to use the trailing slash version for collections, and no trailing slash for non-collection resources. This was the goal of the very wrong PR #1775. Leaving this here for future reference, if anyone wants to pick it up.
Bug report
Describe the bug
When the music files are stored on a distant webdav server, for example :
and the database is local :
Triggering a database update after no change whatsoever to the files causes the (unreasonably slow, even when taking into account that the files are remote) removal of all the music files, and their subsequent re-adding (at reasonable speed considering the files are distant) immediately after.
Expected Behavior
We would expect the database update to cause no removals and no additions, since nothing has changed on the remote filesystem.
Actual Behavior
We have the complete emptying of the database, followed by its immediate refilling (the end result is the same as what we had before the database update).
Version
Configuration
The website
musique.ricorambo.su
is a real one, it can be used for reproducing. I advise to reduce to a specific subdirectory, as I've done here, to gain time.Log
The relevant part of the mpd log, starting with a clean database :
The relevant webdav logs :
Personal enquiries and hypotheses
The most interesting line in my opinion is this one :
I may be wrong, but
PROPFIND
is never supposed to return an empty response. When I tried the same request with curl interactively, curl just waited for the end of the response that never came (I did not have the patience to wait until the likely timeout).The empty response may have something to do with the missing slash at the end of the URL : in fact,
1998%20-%2030-%20Very%20Best%20Of
is a directory, not a regular file.Another clue is that this problem is not reproduced if I set
music_directory
to a directory that does not contain any directories itself, like"http://musique.ricorambo.su/Deep%20Purple/1998%20-%2030-%20Very%20Best%20Of/"
. In this case, the only files that are passed toPROPFIND
are regular files, and so no ending slash is needed. And I've checked, noPROPFIND
request returns any200 0
response.My explanation is that
mpd
, at some point inside the code atsrc/storage/plugins/CurlStorage.cxx
, produces a wrongPROPFIND
request on a directory with a missing trailing slash, this request produces a200 0
response after a timeout (probably 60 seconds by looking at the timestamps). Becausempd
cannot get any information on the directory, it removes it from the database. The files are then added again because this time the request is correctly built (notice the trailing slash) :I am not familiar with the code at
src/storage/plugins/CurlStorage.cxx
, which is why I've come to bother you with this problem. I hope I have provided you with enough information. If not, please ask.I thank you in advance for your time, and I thank you again for this fantastic software.
Mit freundlichen Grüssen,
Aymeric Agon-Rambosson