MusicPlayerDaemon / MPD

Music Player Daemon
https://www.musicpd.org/
GNU General Public License v2.0
2.18k stars 351 forks source link

curl storage : database update removes and re-adds everything #1768

Closed aagon closed 1 year ago

aagon commented 1 year ago

Bug report

Describe the bug

When the music files are stored on a distant webdav server, for example :

music_directory "http://musique.ricorambo.su/"

and the database is local :

database {
    plugin "simple"
    path "~/.config/mpd/mpd.db"
    cache_directory "~/.config/mpd/cache"
}

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

Music Player Daemon 0.23.12 (0.23.12)
Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>
Copyright 2008-2021 Max Kellermann <max.kellermann@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Database plugins:
 simple proxy upnp

Storage plugins:
 local smbclient udisks nfs curl

Neighbor plugins:
 smbclient upnp udisks

Decoders plugins:
 [mad] mp3 mp2
 [mpg123] mp3
 [vorbis] ogg oga
 [oggflac] ogg oga
 [flac] flac
 [opus] opus ogg oga
 [sndfile] wav aiff aif au snd paf iff svx sf voc w64 pvf xi htk caf sd2
 [dsdiff] dff
 [dsf] dsf
 [hybrid_dsd] m4a
 [faad] aac
 [mpcdec] mpc
 [wavpack] wv
 [openmpt] mptm mod s3m xm it 669 amf ams c67 dbm digi dmf dsm dtm far imf ice j2b m15 mdl med mms mt2 mtm nst okt plm psm pt36 ptm sfx sfx2 st26 stk stm stp ult wow gdm mo3 oxm umx xpk ppm mmcmp
 [modplug] 669 amf ams dbm dfm dsm far it med mdl mod mtm mt2 okt s3m stm ult umx xm
 [mikmod] amf dsm far gdm imf it med mod mtm s3m stm stx ult uni xm
 [sidplay] sid mus str prg P00
 [wildmidi] mid
 [fluidsynth] mid
 [adplug] amd d00 hsc laa rad raw sa2
 [ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 adx afc aif aifc aiff al alaw amr anim apc ape asf atrac au aud avi avm2 avs bap bfi c93 cak cin cmv cpk daud dct divx dts dv dvd dxa eac3 film flac flc fli fll flx flv g726 gsm gxf iss m1v m2v m2t m2ts m4a m4b m4v mad mj2 mjpeg mjpg mka mkv mlp mm mmf mov mp+ mp1 mp2 mp3 mp4 mpc mpeg mpg mpga mpp mpu mve mvi mxf nc nsv nut nuv oga ogm ogv ogx oma ogg omg opus psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tak tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav webm wma wmv wsaud wsvga wv wve rtp:// rtsp:// rtsps://
 [gme] ay gbs gym hes kss nsf nsfe rsn sap spc vgm vgz
 [pcm]

Filters:
 libsamplerate soxr

Tag plugins:
 id3tag

Output plugins:
 shout null fifo sndio pipe alsa ao oss openal pipewire pulse jack httpd snapcast recorder

Encoder plugins:
 null vorbis opus lame wave flac

Archive plugins:
 [bz2] bz2
 [zzip] zip
 [iso] iso

Input plugins:
 file io_uring archive alsa curl ffmpeg smbclient nfs mms cdio_paranoia

Playlist plugins:
 extm3u m3u pls xspf asx rss soundcloud flac cue embcue

Protocols:
 file:// alsa:// cdda:// ftp:// ftps:// gopher:// hls+http:// hls+https:// http:// https:// mms:// mmsh:// mmst:// mmsu:// nfs:// rtmp:// rtmps:// rtmpt:// rtmpts:// rtp:// rtsp:// rtsps:// scp:// sftp:// smb:// srtp://

Other features:
 avahi dbus udisks epoll icu inotify ipv6 systemd tcp un

Configuration

music_directory         "http://musique.ricorambo.su/Deep Purple/"
playlist_directory      "~/.config/mpd/playlists"
log_file            "~/.config/mpd/mpd.log"
pid_file            "~/.config/mpd/pid"
state_file          "~/.config/mpd/state"
bind_to_address         "~/.config/mpd/socket"
port                "6600"

database {
    plugin "simple"
    path "~/.config/mpd/mpd.db"
    cache_directory "~/.config/mpd/cache"
}

input_cache {
    size "100 MB"
}

audio_output {
    type        "pulse"
    name        "pulse audio"
}

audio_output {
    type        "fifo"
    name        "mpd_fifo"
    path        "/tmp/mpd.fifo"
    format      "44100:16:2"
}

filesystem_charset      "UTF-8"

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 :

Mar 22 02:50 : event: RTIOThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
Mar 22 02:50 : update: spawned thread for update job id 1
Mar 22 02:50 : state_file: Loading state file /home/rico/.config/mpd/state
Mar 22 02:50 : update: starting
Mar 22 02:51 : exception: CURL failed: The requested URL returned error: 404 Not Found
Mar 22 02:51 : exception: CURL failed: The requested URL returned error: 404 Not Found
Mar 22 02:51 : update: reading 1998 - 30- Very Best Of/08. Deep Purple - Smoke on the Water.flac
Mar 22 02:51 : update: added 1998 - 30- Very Best Of/08. Deep Purple - Smoke on the Water.flac
[snip]
Mar 22 02:51 : update: reading 1998 - 30- Very Best Of/11. Deep Purple - Never Before.flac
Mar 22 02:51 : update: added 1998 - 30- Very Best Of/11. Deep Purple - Never Before.flac
Mar 22 02:51 : simple_db: removing empty directories from DB
Mar 22 02:51 : simple_db: sorting DB
Mar 22 02:51 : simple_db: writing DB
Mar 22 02:51 : update: finished
Mar 22 02:53 : update: starting
Mar 22 02:53 : exception: CURL failed: The requested URL returned error: 404 Not Found
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/16. Deep Purple - Perfect Strangers.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/15. Deep Purple - You Keep on Moving.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/14. Deep Purple - Stormbringer.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/13. Deep Purple - Burn.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/12. Deep Purple - Woman From Tokyo.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/11. Deep Purple - Never Before.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/10. Deep Purple - When a Blind Man Cries.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/09. Deep Purple - Highway Star.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/08. Deep Purple - Smoke on the Water.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/07. Deep Purple - Demon's Eye.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/06. Deep Purple - Fireball.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/05. Deep Purple - Strange Kind of Woman.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/04. Deep Purple - Child in Time.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/03. Deep Purple - Speed King.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/02. Deep Purple - Black Night.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/01. Deep Purple - Hush.flac
Mar 22 02:54 : update: removing 1998 - 30- Very Best Of/17. Deep Purple - Ted the Mechanic.flac
Mar 22 02:54 : exception: CURL failed: The requested URL returned error: 404 Not Found
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/08. Deep Purple - Smoke on the Water.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/08. Deep Purple - Smoke on the Water.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/01. Deep Purple - Hush.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/01. Deep Purple - Hush.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/17. Deep Purple - Ted the Mechanic.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/17. Deep Purple - Ted the Mechanic.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/03. Deep Purple - Speed King.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/03. Deep Purple - Speed King.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/16. Deep Purple - Perfect Strangers.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/16. Deep Purple - Perfect Strangers.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/15. Deep Purple - You Keep on Moving.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/15. Deep Purple - You Keep on Moving.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/02. Deep Purple - Black Night.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/02. Deep Purple - Black Night.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/07. Deep Purple - Demon's Eye.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/07. Deep Purple - Demon's Eye.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/05. Deep Purple - Strange Kind of Woman.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/05. Deep Purple - Strange Kind of Woman.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/14. Deep Purple - Stormbringer.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/14. Deep Purple - Stormbringer.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/09. Deep Purple - Highway Star.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/09. Deep Purple - Highway Star.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/10. Deep Purple - When a Blind Man Cries.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/10. Deep Purple - When a Blind Man Cries.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/04. Deep Purple - Child in Time.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/04. Deep Purple - Child in Time.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/13. Deep Purple - Burn.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/13. Deep Purple - Burn.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/06. Deep Purple - Fireball.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/06. Deep Purple - Fireball.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/12. Deep Purple - Woman From Tokyo.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/12. Deep Purple - Woman From Tokyo.flac
Mar 22 02:54 : update: reading 1998 - 30- Very Best Of/11. Deep Purple - Never Before.flac
Mar 22 02:54 : update: added 1998 - 30- Very Best Of/11. Deep Purple - Never Before.flac
Mar 22 02:54 : simple_db: removing empty directories from DB
Mar 22 02:54 : simple_db: sorting DB
Mar 22 02:54 : simple_db: writing DB
Mar 22 02:54 : update: finished

The relevant webdav logs :

192.168.1.57 - - [22/Mar/2023:02:51:00 +0100] "PROPFIND /Deep Purple/ HTTP/1.1" 207 533 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:51:00 +0100] "PROPFIND /Deep Purple/ HTTP/1.1" 207 954 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:51:00 +0100] "GET /Deep Purple/.mpdignore HTTP/1.1" 404 341 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:51:00 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/ HTTP/1.1" 207 9590 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:51:00 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/.mpdignore HTTP/1.1" 404 341 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:51:00 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/08.%20Deep%20Purple%20-%20Smoke%20on%20the%20Water.flac HTTP/1.1" 207 585 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:51:01 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/08.%20Deep%20Purple%20-%20Smoke%20on%20the%20Water.flac HTTP/1.1" 200 98084 "-" "Music Player Daemon 0.23.12"
[snip]
192.168.1.57 - - [22/Mar/2023:02:51:02 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/11.%20Deep%20Purple%20-%20Never%20Before.flac HTTP/1.1" 207 575 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:51:02 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/11.%20Deep%20Purple%20-%20Never%20Before.flac HTTP/1.1" 200 109331 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:53:26 +0100] "PROPFIND /Deep Purple/ HTTP/1.1" 207 533 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:53:26 +0100] "PROPFIND /Deep Purple/ HTTP/1.1" 207 954 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:53:26 +0100] "GET /Deep Purple/.mpdignore HTTP/1.1" 404 341 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:26 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of HTTP/1.1" 200 0 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:26 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/ HTTP/1.1" 207 9590 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:26 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/.mpdignore HTTP/1.1" 404 341 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:26 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/08.%20Deep%20Purple%20-%20Smoke%20on%20the%20Water.flac HTTP/1.1" 207 585 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:26 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/08.%20Deep%20Purple%20-%20Smoke%20on%20the%20Water.flac HTTP/1.1" 200 24356 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/01.%20Deep%20Purple%20-%20Hush.flac HTTP/1.1" 207 565 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/01.%20Deep%20Purple%20-%20Hush.flac HTTP/1.1" 200 40741 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/17.%20Deep%20Purple%20-%20Ted%20the%20Mechanic.flac HTTP/1.1" 207 581 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/17.%20Deep%20Purple%20-%20Ted%20the%20Mechanic.flac HTTP/1.1" 200 32547 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/03.%20Deep%20Purple%20-%20Speed%20King.flac HTTP/1.1" 207 573 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/03.%20Deep%20Purple%20-%20Speed%20King.flac HTTP/1.1" 200 93988 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/16.%20Deep%20Purple%20-%20Perfect%20Strangers.flac HTTP/1.1" 207 580 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/16.%20Deep%20Purple%20-%20Perfect%20Strangers.flac HTTP/1.1" 200 86163 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/15.%20Deep%20Purple%20-%20You%20Keep%20on%20Moving.flac HTTP/1.1" 207 585 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/15.%20Deep%20Purple%20-%20You%20Keep%20on%20Moving.flac HTTP/1.1" 200 69411 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/02.%20Deep%20Purple%20-%20Black%20Night.flac HTTP/1.1" 207 574 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/02.%20Deep%20Purple%20-%20Black%20Night.flac HTTP/1.1" 200 65315 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/07.%20Deep%20Purple%20-%20Demon%27s%20Eye.flac HTTP/1.1" 207 576 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/07.%20Deep%20Purple%20-%20Demon%27s%20Eye.flac HTTP/1.1" 200 65315 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/05.%20Deep%20Purple%20-%20Strange%20Kind%20of%20Woman.flac HTTP/1.1" 207 588 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/05.%20Deep%20Purple%20-%20Strange%20Kind%20of%20Woman.flac HTTP/1.1" 200 48931 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/14.%20Deep%20Purple%20-%20Stormbringer.flac HTTP/1.1" 207 573 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/14.%20Deep%20Purple%20-%20Stormbringer.flac HTTP/1.1" 200 106276 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/09.%20Deep%20Purple%20-%20Highway%20Star.flac HTTP/1.1" 207 575 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/09.%20Deep%20Purple%20-%20Highway%20Star.flac HTTP/1.1" 200 85795 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/10.%20Deep%20Purple%20-%20When%20a%20Blind%20Man%20Cries.flac HTTP/1.1" 207 591 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/10.%20Deep%20Purple%20-%20When%20a%20Blind%20Man%20Cries.flac HTTP/1.1" 200 32547 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/04.%20Deep%20Purple%20-%20Child%20in%20Time.flac HTTP/1.1" 207 578 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/04.%20Deep%20Purple%20-%20Child%20in%20Time.flac HTTP/1.1" 200 65315 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/13.%20Deep%20Purple%20-%20Burn.flac HTTP/1.1" 207 565 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/13.%20Deep%20Purple%20-%20Burn.flac HTTP/1.1" 200 102179 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/06.%20Deep%20Purple%20-%20Fireball.flac HTTP/1.1" 207 569 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/06.%20Deep%20Purple%20-%20Fireball.flac HTTP/1.1" 200 16163 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/12.%20Deep%20Purple%20-%20Woman%20From%20Tokyo.flac HTTP/1.1" 207 581 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/12.%20Deep%20Purple%20-%20Woman%20From%20Tokyo.flac HTTP/1.1" 200 40739 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/11.%20Deep%20Purple%20-%20Never%20Before.flac HTTP/1.1" 207 575 "-" "Music Player Daemon 0.23.12"
192.168.1.57 - - [22/Mar/2023:02:54:28 +0100] "GET /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/11.%20Deep%20Purple%20-%20Never%20Before.flac HTTP/1.1" 200 7971 "-" "Music Player Daemon 0.23.12"

Personal enquiries and hypotheses

The most interesting line in my opinion is this one :

192.168.1.57 - - [22/Mar/2023:02:54:26 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of HTTP/1.1" 200 0 "-" "Music Player Daemon 0.23.12"

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 to PROPFIND are regular files, and so no ending slash is needed. And I've checked, no PROPFIND request returns any 200 0 response.

My explanation is that mpd, at some point inside the code at src/storage/plugins/CurlStorage.cxx, produces a wrong PROPFIND request on a directory with a missing trailing slash, this request produces a 200 0 response after a timeout (probably 60 seconds by looking at the timestamps). Because mpd 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) :

192.168.1.57 - - [22/Mar/2023:02:54:26 +0100] "PROPFIND /Deep Purple/1998%20-%2030-%20Very%20Best%20Of/ HTTP/1.1" 207 9590 "-" "Music Player Daemon 0.23.12"

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

aagon commented 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.

MaxKellermann commented 1 year ago

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.

aagon commented 1 year ago

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.