Make a backup of configuration when we load in a Version 2 file, and bump our config...
[dcpomatic.git] / src / lib / cinema_kdms.cc
index 1ec8546201895d0c5f247492a887960446c87e10..d4c1017bb6bcb1846332be77ba7559ba0af6f8d5 100644 (file)
@@ -65,6 +65,7 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam
                }
 
                name_values['s'] = i.screen->name;
+               name_values['i'] = i.kdm.id ();
                string const name = name_format.get(name_values, ".xml");
                if (zip_add (zip, name.c_str(), source) == -1) {
                        throw runtime_error ("failed to add KDM to ZIP archive");
@@ -130,14 +131,15 @@ CinemaKDMs::write_directories (
 
        int written = 0;
 
+       if (!boost::filesystem::exists (directory)) {
+               boost::filesystem::create_directories (directory);
+       }
+
        BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
                boost::filesystem::path path = directory;
                name_values['c'] = i.cinema->name;
                path /= container_name_format.get(name_values, "");
-               if (!boost::filesystem::exists (path) || confirm_overwrite (path)) {
-                       boost::filesystem::create_directories (path);
-                       ScreenKDM::write_files (i.screen_kdms, path, filename_format, name_values, confirm_overwrite);
-               }
+               ScreenKDM::write_files (i.screen_kdms, path, filename_format, name_values, confirm_overwrite);
                written += i.screen_kdms.size();
        }
 
@@ -160,6 +162,10 @@ CinemaKDMs::write_zip_files (
 
        int written = 0;
 
+       if (!boost::filesystem::exists (directory)) {
+               boost::filesystem::create_directories (directory);
+       }
+
        BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
                boost::filesystem::path path = directory;
                name_values['c'] = i.cinema->name;
@@ -208,7 +214,8 @@ CinemaKDMs::email (
 
                name_values['c'] = i.cinema->name;
 
-               boost::filesystem::path zip_file = boost::filesystem::temp_directory_path();
+               boost::filesystem::path zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
+               boost::filesystem::create_directories (zip_file);
                zip_file /= container_name_format.get(name_values, ".zip");
                i.make_zip_file (zip_file, filename_format, name_values);