From c88056ba83183bfbdd0f8ed67aaa4ff02802ab11 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 21 Dec 2017 10:16:52 +0100 Subject: [PATCH] db/simple: fix file corruption in the presence of mount points If a directory is a mount point, omit the "directory: " as well. This bug is years old, but has become more visible now that mount points are persistent in the state file. --- NEWS | 2 ++ src/db/plugins/simple/DirectorySave.cxx | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 0b824cdd1..7ae86d430 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.20.14 (not yet released) +* database + - simple: fix file corruption in the presence of mount points ver 0.20.13 (2017/12/18) * output diff --git a/src/db/plugins/simple/DirectorySave.cxx b/src/db/plugins/simple/DirectorySave.cxx index e1f83bf5b..033d90f4a 100644 --- a/src/db/plugins/simple/DirectorySave.cxx +++ b/src/db/plugins/simple/DirectorySave.cxx @@ -82,10 +82,11 @@ directory_save(BufferedOutputStream &os, const Directory &directory) } for (const auto &child : directory.children) { - os.Format(DIRECTORY_DIR "%s\n", child.GetName()); + if (child.IsMount()) + continue; - if (!child.IsMount()) - directory_save(os, child); + os.Format(DIRECTORY_DIR "%s\n", child.GetName()); + directory_save(os, child); } for (const auto &song : directory.songs)