Add config location versioning (#2090).
authorCarl Hetherington <cth@carlh.net>
Sat, 25 Sep 2021 22:09:04 +0000 (00:09 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 27 Sep 2021 09:32:49 +0000 (11:32 +0200)
16 files changed:
src/lib/analytics.cc
src/lib/config.cc
src/lib/config.h
src/lib/cross.h
src/lib/cross_linux.cc
src/lib/cross_osx.cc
src/lib/cross_windows.cc
src/lib/film.cc
src/lib/state.cc
src/lib/state.h
src/tools/dcpomatic.cc
src/tools/dcpomatic_disk.cc
src/tools/dcpomatic_disk_writer.cc
src/wx/full_config_dialog.cc
test/config_test.cc
test/data

index ac0abc22273c182be40e3294934f2d4a701214d8..7483166bad72bc444d006dd93ac0ff4b32109a7c 100644 (file)
@@ -96,11 +96,11 @@ Analytics::write () const
        root->add_child("SuccessfulDCPEncodes")->add_child_text(raw_convert<string>(_successful_dcp_encodes));
 
        try {
-               doc.write_to_file_formatted(path("analytics.xml").string());
+               doc.write_to_file_formatted(write_path("analytics.xml").string());
        } catch (xmlpp::exception& e) {
                string s = e.what ();
                trim (s);
-               throw FileError (s, path("analytics.xml"));
+               throw FileError (s, write_path("analytics.xml"));
        }
 }
 
@@ -110,7 +110,7 @@ Analytics::read ()
 try
 {
        cxml::Document f ("Analytics");
-       f.read_file (path("analytics.xml"));
+       f.read_file (read_path("analytics.xml"));
        _successful_dcp_encodes = f.number_child<int>("SuccessfulDCPEncodes");
 } catch (...) {
        /* Never mind */
index 15abff3917635a7ce4ab489962bf54101d723a68..4aa4788bf1493001945ee06ef57fcbb4cc4e94f0 100644 (file)
@@ -125,8 +125,8 @@ Config::set_defaults ()
 #ifdef DCPOMATIC_WINDOWS
        _win32_console = false;
 #endif
-       _cinemas_file = path ("cinemas.xml");
-       _dkdm_recipients_file = path ("dkdm_recipients.xml");
+       _cinemas_file = read_path ("cinemas.xml");
+       _dkdm_recipients_file = read_path ("dkdm_recipients.xml");
        _show_hints_before_make_dcp = true;
        _confirm_kdm_email = true;
        _kdm_container_name_format = dcp::NameFormat ("KDM %f %c");
@@ -216,13 +216,13 @@ Config::backup ()
        /* Make a copy of the configuration */
        try {
                int n = 1;
-               while (n < 100 && boost::filesystem::exists(path(String::compose("config.xml.%1", n)))) {
+               while (n < 100 && boost::filesystem::exists(write_path(String::compose("config.xml.%1", n)))) {
                        ++n;
                }
 
-               boost::filesystem::copy_file(path("config.xml", false), path(String::compose("config.xml.%1", n), false));
-               boost::filesystem::copy_file(path("cinemas.xml", false), path(String::compose("cinemas.xml.%1", n), false));
-               boost::filesystem::copy_file(path("dkdm_recipients.xml", false), path(String::compose("dkdm_recipients.xml.%1", n), false));
+               boost::filesystem::copy_file(read_path("config.xml"), write_path(String::compose("config.xml.%1", n)));
+               boost::filesystem::copy_file(read_path("cinemas.xml"), write_path(String::compose("cinemas.xml.%1", n)));
+               boost::filesystem::copy_file(read_path("dkdm_recipients.xml"), write_path(String::compose("dkdm_recipients.xml.%1", n)));
        } catch (...) {}
 }
 
@@ -231,7 +231,7 @@ Config::read ()
 try
 {
        cxml::Document f ("Config");
-       f.read_file (config_file ());
+       f.read_file (config_read_file());
 
        auto version = f.optional_number_child<int> ("Version");
        if (version && *version < _current_version) {
@@ -467,8 +467,8 @@ try
                        _dkdms->add (DKDMBase::read (i));
                }
        }
-       _cinemas_file = f.optional_string_child("CinemasFile").get_value_or (path ("cinemas.xml").string ());
-       _dkdm_recipients_file = f.optional_string_child("DKDMRecipientsFile").get_value_or (path("dkdm_recipients.xml").string());
+       _cinemas_file = f.optional_string_child("CinemasFile").get_value_or(read_path("cinemas.xml").string());
+       _dkdm_recipients_file = f.optional_string_child("DKDMRecipientsFile").get_value_or(read_path("dkdm_recipients.xml").string());
        _show_hints_before_make_dcp = f.optional_bool_child("ShowHintsBeforeMakeDCP").get_value_or (true);
        _confirm_kdm_email = f.optional_bool_child("ConfirmKDMEmail").get_value_or (true);
        _kdm_container_name_format = dcp::NameFormat (f.optional_string_child("KDMContainerNameFormat").get_value_or ("KDM %f %c"));
@@ -993,21 +993,23 @@ Config::write_config () const
                root->add_child("AddFilesPath")->add_child_text(_add_files_path->string());
        }
 
+       auto target = config_write_file();
+
        try {
                auto const s = doc.write_to_string_formatted ();
-               boost::filesystem::path tmp (string(config_file().string()).append(".tmp"));
+               boost::filesystem::path tmp (string(target.string()).append(".tmp"));
                auto f = fopen_boost (tmp, "w");
                if (!f) {
                        throw FileError (_("Could not open file for writing"), tmp);
                }
                checked_fwrite (s.c_str(), s.bytes(), f, tmp);
                fclose (f);
-               boost::filesystem::remove (config_file());
-               boost::filesystem::rename (tmp, config_file());
+               boost::filesystem::remove (target);
+               boost::filesystem::rename (tmp, target);
        } catch (xmlpp::exception& e) {
                string s = e.what ();
                trim (s);
-               throw FileError (s, config_file());
+               throw FileError (s, target);
        }
 }
 
@@ -1201,12 +1203,14 @@ Config::clean_history_internal (vector<boost::filesystem::path>& h)
        }
 }
 
+
 bool
 Config::have_existing (string file)
 {
-       return boost::filesystem::exists (path (file, false));
+       return boost::filesystem::exists (read_path(file));
 }
 
+
 void
 Config::read_cinemas (cxml::Document const & f)
 {
@@ -1273,18 +1277,19 @@ Config::set_dkdm_recipients_file (boost::filesystem::path file)
 void
 Config::save_template (shared_ptr<const Film> film, string name) const
 {
-       film->write_template (template_path (name));
+       film->write_template (template_write_path(name));
 }
 
+
 list<string>
 Config::templates () const
 {
-       if (!boost::filesystem::exists (path ("templates"))) {
+       if (!boost::filesystem::exists(read_path("templates"))) {
                return {};
        }
 
        list<string> n;
-       for (auto const& i: boost::filesystem::directory_iterator(path("templates"))) {
+       for (auto const& i: boost::filesystem::directory_iterator(read_path("templates"))) {
                n.push_back (i.path().filename().string());
        }
        return n;
@@ -1293,33 +1298,41 @@ Config::templates () const
 bool
 Config::existing_template (string name) const
 {
-       return boost::filesystem::exists (template_path (name));
+       return boost::filesystem::exists (template_read_path(name));
 }
 
+
 boost::filesystem::path
-Config::template_path (string name) const
+Config::template_read_path (string name) const
 {
-       return path("templates") / tidy_for_filename (name);
+       return read_path("templates") / tidy_for_filename (name);
 }
 
+
+boost::filesystem::path
+Config::template_write_path (string name) const
+{
+       return write_path("templates") / tidy_for_filename (name);
+}
+
+
 void
 Config::rename_template (string old_name, string new_name) const
 {
-       boost::filesystem::rename (template_path (old_name), template_path (new_name));
+       boost::filesystem::rename (template_read_path(old_name), template_write_path(new_name));
 }
 
 void
 Config::delete_template (string name) const
 {
-       boost::filesystem::remove (template_path (name));
+       boost::filesystem::remove (template_write_path(name));
 }
 
 /** @return Path to the config.xml containing the actual settings, following a link if required */
 boost::filesystem::path
-Config::config_file ()
+config_file (boost::filesystem::path main)
 {
        cxml::Document f ("Config");
-       auto main = path("config.xml", false);
        if (!boost::filesystem::exists (main)) {
                /* It doesn't exist, so there can't be any links; just return it */
                return main;
@@ -1341,6 +1354,21 @@ Config::config_file ()
        return main;
 }
 
+
+boost::filesystem::path
+Config::config_read_file ()
+{
+       return config_file (read_path("config.xml"));
+}
+
+
+boost::filesystem::path
+Config::config_write_file ()
+{
+       return config_file (write_path("config.xml"));
+}
+
+
 void
 Config::reset_cover_sheet ()
 {
@@ -1354,11 +1382,11 @@ Config::link (boost::filesystem::path new_file) const
        xmlpp::Document doc;
        doc.create_root_node("Config")->add_child("Link")->add_child_text(new_file.string());
        try {
-               doc.write_to_file_formatted(path("config.xml", true).string());
+               doc.write_to_file_formatted(write_path("config.xml").string());
        } catch (xmlpp::exception& e) {
                string s = e.what ();
                trim (s);
-               throw FileError (s, path("config.xml"));
+               throw FileError (s, write_path("config.xml"));
        }
 }
 
@@ -1366,14 +1394,14 @@ void
 Config::copy_and_link (boost::filesystem::path new_file) const
 {
        write ();
-       boost::filesystem::copy_file (config_file(), new_file, boost::filesystem::copy_option::overwrite_if_exists);
+       boost::filesystem::copy_file (config_read_file(), new_file, boost::filesystem::copy_option::overwrite_if_exists);
        link (new_file);
 }
 
 bool
 Config::have_write_permission () const
 {
-       auto f = fopen_boost (config_file(), "r+");
+       auto f = fopen_boost (config_write_file(), "r+");
        if (!f) {
                return false;
        }
index 46bd390cc8628773edd0e476781c099f016c794f..5981e799488f0a1dd7ad8a3b2a4a1d13c1d91983 100644 (file)
@@ -1095,7 +1095,8 @@ public:
        void save_template (std::shared_ptr<const Film> film, std::string name) const;
        bool existing_template (std::string name) const;
        std::list<std::string> templates () const;
-       boost::filesystem::path template_path (std::string name) const;
+       boost::filesystem::path template_read_path (std::string name) const;
+       boost::filesystem::path template_write_path (std::string name) const;
        void rename_template (std::string old_name, std::string new_name) const;
        void delete_template (std::string name) const;
 
@@ -1103,7 +1104,8 @@ public:
        static void drop ();
        static void restore_defaults ();
        static bool have_existing (std::string);
-       static boost::filesystem::path config_file ();
+       static boost::filesystem::path config_read_file ();
+       static boost::filesystem::path config_write_file ();
 
 private:
        Config ();
index 91911330577d3a1991b6bcc4e1699f0095ab3927..ed1d0c8e780836cc3281d89a314e5fc16580bb34 100644 (file)
@@ -64,7 +64,7 @@ extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int f
 extern boost::filesystem::path home_directory ();
 extern bool running_32_on_64 ();
 extern void unprivileged ();
-extern boost::filesystem::path config_path ();
+extern boost::filesystem::path config_path (boost::optional<std::string> version);
 extern boost::filesystem::path directory_containing_executable ();
 extern boost::filesystem::path fix_long_path (boost::filesystem::path path);
 extern bool show_in_file_manager (boost::filesystem::path dir, boost::filesystem::path select);
index 2fcec28910013fea3ef54cfc8519cbb5a49272ad..ee49d50bc8ef8972da9f13d25b7f90680fc49396 100644 (file)
@@ -379,11 +379,14 @@ Drive::unmount ()
 
 
 boost::filesystem::path
-config_path ()
+config_path (optional<string> version)
 {
        boost::filesystem::path p;
        p /= g_get_user_config_dir ();
        p /= "dcpomatic2";
+       if (version) {
+               p /= *version;
+       }
        return p;
 }
 
index d0cb9f216980846307f70c84745e98a38f5a18be..ff40ffb708aa8666a2e279b8362ce34663abd8c1 100644 (file)
@@ -552,7 +552,7 @@ Drive::get ()
 
 
 boost::filesystem::path
-config_path ()
+config_path (optional<string> version)
 {
        boost::filesystem::path p;
        p /= g_get_home_dir ();
@@ -560,6 +560,9 @@ config_path ()
        p /= "Preferences";
        p /= "com.dcpomatic";
        p /= "2";
+       if (version) {
+               p /= *version;
+       }
        return p;
 }
 
index 723828d7e235dce6617e01041389756ad6201620..b3d9a1558add1fbd2f7e70a74a23b2017accc985 100644 (file)
@@ -672,11 +672,14 @@ Drive::unmount ()
 
 
 boost::filesystem::path
-config_path ()
+config_path (optional<string> version)
 {
        boost::filesystem::path p;
        p /= g_get_user_config_dir ();
        p /= "dcpomatic2";
+       if (version) {
+               p /= *version;
+       }
        return p;
 }
 
index 3e6430ee36b6cedf0dfd50669f44b487a91ac0d4..0d277b82a0a8e92c1825eedc86dc6b08c7b3085c 100644 (file)
@@ -1921,7 +1921,7 @@ void
 Film::use_template (string name)
 {
        _template_film.reset (new Film (optional<boost::filesystem::path>()));
-       _template_film->read_metadata (Config::instance()->template_path (name));
+       _template_film->read_metadata (Config::instance()->template_read_path(name));
        _use_isdcf_name = _template_film->_use_isdcf_name;
        _dcp_content_type = _template_film->_dcp_content_type;
        _container = _template_film->_container;
index 5f7e9a701bebcb0ee9272ab79ef99457912c9952..e22f9e0b98bd71d37f4e6947d1563b1b6afd01c2 100644 (file)
 */
 
 
-#include "state.h"
 #include "cross.h"
+#include "state.h"
+#include "util.h"
 #include <glib.h>
 
 
 using std::string;
+using boost::optional;
 
 
 boost::optional<boost::filesystem::path> State::override_path;
 
 
+/* List of config versions to look for in descending order of preference;
+ * i.e. look at the first one, and if that doesn't exist, try the second, etc.
+ */
+static std::vector<std::string> config_versions = { "2.16" };
+
+
+static
+boost::filesystem::path
+config_path_or_override (optional<string> version)
+{
+       if (State::override_path) {
+               auto p = *State::override_path;
+               if (version) {
+                       p /= *version;
+               }
+               return p;
+       }
+
+       return config_path (version);
+}
+
+
 /** @param file State filename
- *  @return Full path to write @file to.
+ *  @return Full path to read @file from.
  */
 boost::filesystem::path
-State::path (string file, bool create_directories)
+State::read_path (string file)
 {
-       boost::filesystem::path p;
-       if (override_path) {
-               p = *override_path;
-       } else {
-               p = config_path ();
+       using namespace boost::filesystem;
+
+       for (auto i: config_versions) {
+               auto full = config_path_or_override(i) / file;
+               if (exists(full)) {
+                       return full;
+               }
        }
+
+       return config_path_or_override({}) / file;
+}
+
+
+/** @param file State filename
+ *  @return Full path to write @file to.
+ */
+boost::filesystem::path
+State::write_path (string file)
+{
+       boost::filesystem::path p = config_path_or_override(config_versions.front());
        boost::system::error_code ec;
-       if (create_directories) {
-               boost::filesystem::create_directories (p, ec);
-       }
+       boost::filesystem::create_directories (p, ec);
        p /= file;
        return p;
 }
+
index f1ed775a2b2df00a8b1ef3445e1a329dbf5f18e9..9338aae0c2cdff64f769ff179cebd56c452f0f0b 100644 (file)
@@ -40,7 +40,8 @@ public:
 
        /** If set, this overrides the standard path (in home, Library, AppData or wherever) for config.xml, cinemas.xml etc. */
        static boost::optional<boost::filesystem::path> override_path;
-       static boost::filesystem::path path (std::string file, bool create_directories = true);
+       static boost::filesystem::path read_path (std::string file);
+       static boost::filesystem::path write_path (std::string file);
 };
 
 
index ca45963f440a90b52cf0dd4b4c330501436a2b99..0b7f632e1ef409613c11263ba8cc78e89c06b7e4 100644 (file)
@@ -933,7 +933,7 @@ private:
                                _("You are making a DKDM which is encrypted by a private key held in"
                                  "\n\n<tt>%s</tt>\n\nIt is <span weight=\"bold\" size=\"larger\">VITALLY IMPORTANT</span> "
                                  "that you <span weight=\"bold\" size=\"larger\">BACK UP THIS FILE</span> since if it is lost "
-                                 "your DKDMs (and the DCPs they protect) will become useless."), std_to_wx(Config::config_file().string()).data()
+                                 "your DKDMs (and the DCPs they protect) will become useless."), std_to_wx(Config::config_read_file().string()).data()
                                )
                        );
 
index 7e43c068469ae74149671ca1124971e9d7f46727..ec5d8e782db122dc4a15814432aa3ddae5bb2f2c 100644 (file)
@@ -139,7 +139,7 @@ public:
                /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's
                 * a better place to put them.
                 */
-               dcpomatic_log.reset(new FileLog(config_path() / "disk.log"));
+               dcpomatic_log = make_shared<FileLog>(State::write_path("disk.log"));
                dcpomatic_log->set_types (dcpomatic_log->types() | LogEntry::TYPE_DISK);
                LOG_DISK("dcpomatic_disk %1 started", dcpomatic_git_commit);
 
index c638b72ebd8bf927f30185742d4587fd85f62710..ef384bbbac5d27b2bd0967d98f3c9c818234ead3 100644 (file)
@@ -27,7 +27,9 @@
 #include "lib/exceptions.h"
 #include "lib/ext.h"
 #include "lib/file_log.h"
+#include "lib/state.h"
 #include "lib/nanomsg.h"
+#include "lib/util.h"
 #include "lib/version.h"
 #include "lib/warnings.h"
 
@@ -288,7 +290,7 @@ main ()
        /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's
         * a better place to put them.
         */
-       dcpomatic_log.reset(new FileLog(config_path() / "disk_writer.log", LogEntry::TYPE_DISK));
+       dcpomatic_log.reset(new FileLog(State::write_path("disk_writer.log"), LogEntry::TYPE_DISK));
        LOG_DISK_NC("dcpomatic_disk_writer started");
 #endif
 
index 1d0c1e01acf200c00c346ce713f86b93c21fb2e3..dcfcf394b08c6a67b289259c13d1ecda81f34a3f 100644 (file)
@@ -153,7 +153,7 @@ private:
                checked_set (_analyse_ebur128, config->analyse_ebur128 ());
 #endif
                checked_set (_automatic_audio_analysis, config->automatic_audio_analysis ());
-               checked_set (_config_file, config->config_file());
+               checked_set (_config_file, config->config_read_file());
                checked_set (_cinemas_file, config->cinemas_file());
 
                GeneralPage::config_changed ();
@@ -198,7 +198,7 @@ private:
        {
                auto config = Config::instance();
                boost::filesystem::path new_file = wx_to_std(_config_file->GetPath());
-               if (new_file == config->config_file()) {
+               if (new_file == config->config_read_file()) {
                        return;
                }
                bool copy_and_link = true;
@@ -212,7 +212,7 @@ private:
 
                if (copy_and_link) {
                        config->write ();
-                       if (new_file != config->config_file()) {
+                       if (new_file != config->config_read_file()) {
                                config->copy_and_link (new_file);
                        }
                } else {
index d78b9357b86dc8943fcb5021255392c813fa09ed..173c95cbf9c4fe1cc778b221cead0b8b6f6a4798 100644 (file)
@@ -32,11 +32,11 @@ static void
 rewrite_bad_config ()
 {
        boost::system::error_code ec;
-       boost::filesystem::remove ("build/test/bad_config/config.xml", ec);
+       boost::filesystem::remove ("build/test/bad_config/2.16/config.xml", ec);
 
        Config::override_path = "build/test/bad_config";
-       boost::filesystem::create_directories ("build/test/bad_config");
-       ofstream f ("build/test/bad_config/config.xml");
+       boost::filesystem::create_directories ("build/test/bad_config/2.16");
+       ofstream f ("build/test/bad_config/2.16/config.xml");
        f << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
          << "<Config>\n"
          << "<Foo></Foo>\n"
@@ -57,37 +57,37 @@ BOOST_AUTO_TEST_CASE (config_backup_test)
 
        Config::instance();
 
-       BOOST_CHECK ( boost::filesystem::exists ("build/test/bad_config/config.xml.1"));
-       BOOST_CHECK (!boost::filesystem::exists ("build/test/bad_config/config.xml.2"));
-       BOOST_CHECK (!boost::filesystem::exists ("build/test/bad_config/config.xml.3"));
-       BOOST_CHECK (!boost::filesystem::exists ("build/test/bad_config/config.xml.4"));
+       BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1"));
+       BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2"));
+       BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3"));
+       BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4"));
 
        Config::drop();
        rewrite_bad_config();
        Config::instance();
 
-       BOOST_CHECK ( boost::filesystem::exists ("build/test/bad_config/config.xml.1"));
-       BOOST_CHECK ( boost::filesystem::exists ("build/test/bad_config/config.xml.2"));
-       BOOST_CHECK (!boost::filesystem::exists ("build/test/bad_config/config.xml.3"));
-       BOOST_CHECK (!boost::filesystem::exists ("build/test/bad_config/config.xml.4"));
+       BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1"));
+       BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2"));
+       BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3"));
+       BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4"));
 
        Config::drop();
        rewrite_bad_config();
        Config::instance();
 
-       BOOST_CHECK ( boost::filesystem::exists ("build/test/bad_config/config.xml.1"));
-       BOOST_CHECK ( boost::filesystem::exists ("build/test/bad_config/config.xml.2"));
-       BOOST_CHECK ( boost::filesystem::exists ("build/test/bad_config/config.xml.3"));
-       BOOST_CHECK (!boost::filesystem::exists ("build/test/bad_config/config.xml.4"));
+       BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1"));
+       BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2"));
+       BOOST_CHECK ( boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3"));
+       BOOST_CHECK (!boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4"));
 
        Config::drop();
        rewrite_bad_config();
        Config::instance();
 
-       BOOST_CHECK (boost::filesystem::exists ("build/test/bad_config/config.xml.1"));
-       BOOST_CHECK (boost::filesystem::exists ("build/test/bad_config/config.xml.2"));
-       BOOST_CHECK (boost::filesystem::exists ("build/test/bad_config/config.xml.3"));
-       BOOST_CHECK (boost::filesystem::exists ("build/test/bad_config/config.xml.4"));
+       BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.1"));
+       BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.2"));
+       BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.3"));
+       BOOST_CHECK (boost::filesystem::exists("build/test/bad_config/2.16/config.xml.4"));
 
        /* This test has called Config::set_defaults(), so take us back
           to the config that we want for our tests.
@@ -112,3 +112,24 @@ BOOST_AUTO_TEST_CASE (config_write_utf8_test)
        setup_test_config ();
 }
 
+
+BOOST_AUTO_TEST_CASE (config_upgrade_test)
+{
+       boost::filesystem::path dir = "build/test/config_upgrade_test";
+       Config::override_path = dir;
+       Config::drop ();
+       boost::filesystem::remove_all (dir);
+       boost::filesystem::create_directories (dir);
+
+       boost::filesystem::copy_file ("test/data/2.14.config.xml", dir / "config.xml");
+       boost::filesystem::copy_file ("test/data/2.14.cinemas.xml", dir / "cinemas.xml");
+       Config::instance();
+       Config::instance()->write();
+
+       check_xml (dir / "config.xml", "test/data/2.14.config.xml", {});
+       check_xml (dir / "cinemas.xml", "test/data/2.14.cinemas.xml", {});
+       check_xml (dir / "2.16" / "config.xml", "test/data/2.16.config.xml", {});
+       /* cinemas.xml is not copied into 2.16 as its format has not changed */
+       BOOST_REQUIRE (!boost::filesystem::exists(dir / "2.16" / "cinemas.xml"));
+}
+
index d8d9a1eedc24b5f67f377b6e87e649cdee6fc3b7..56b37afdf96ecc83752ce70af061ee6c7ed4f78b 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit d8d9a1eedc24b5f67f377b6e87e649cdee6fc3b7
+Subproject commit 56b37afdf96ecc83752ce70af061ee6c7ed4f78b