mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-18 20:56:28 +01:00
Allow to cancel session archive process
This commit is contained in:
parent
56176bb627
commit
25f8eea162
1 changed files with 24 additions and 6 deletions
|
|
@ -5618,7 +5618,7 @@ Session::archive_session (const std::string& dest,
|
||||||
string archive = Glib::build_filename (dest, name + session_archive_suffix);
|
string archive = Glib::build_filename (dest, name + session_archive_suffix);
|
||||||
|
|
||||||
PBD::ScopedConnectionList progress_connection;
|
PBD::ScopedConnectionList progress_connection;
|
||||||
PBD::FileArchive ar (archive);
|
PBD::FileArchive ar (archive, progress);
|
||||||
|
|
||||||
/* collect files to archive */
|
/* collect files to archive */
|
||||||
std::map<string,string> filemap;
|
std::map<string,string> filemap;
|
||||||
|
|
@ -5733,6 +5733,13 @@ Session::archive_session (const std::string& dest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<string> extra_files;
|
||||||
|
size_t prefix_len;
|
||||||
|
|
||||||
|
if (progress && progress->cancelled ()) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* encode audio */
|
/* encode audio */
|
||||||
if (compress_audio != NO_ENCODE) {
|
if (compress_audio != NO_ENCODE) {
|
||||||
if (progress) {
|
if (progress) {
|
||||||
|
|
@ -5797,6 +5804,9 @@ Session::archive_session (const std::string& dest,
|
||||||
|
|
||||||
if (progress) {
|
if (progress) {
|
||||||
progress->ascend ();
|
progress->ascend ();
|
||||||
|
if (progress->cancelled ()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5804,6 +5814,9 @@ Session::archive_session (const std::string& dest,
|
||||||
if (progress) {
|
if (progress) {
|
||||||
progress->set_progress (-1); // set to "archiving"
|
progress->set_progress (-1); // set to "archiving"
|
||||||
progress->set_progress (0);
|
progress->set_progress (0);
|
||||||
|
if (progress->cancelled ()) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* index files relevant for this session */
|
/* index files relevant for this session */
|
||||||
|
|
@ -5868,22 +5881,20 @@ Session::archive_session (const std::string& dest,
|
||||||
|
|
||||||
save_default_options ();
|
save_default_options ();
|
||||||
|
|
||||||
size_t prefix_len = _path.size();
|
prefix_len = _path.size();
|
||||||
if (prefix_len > 0 && _path.at (prefix_len - 1) != G_DIR_SEPARATOR) {
|
if (prefix_len > 0 && _path.at (prefix_len - 1) != G_DIR_SEPARATOR) {
|
||||||
++prefix_len;
|
++prefix_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* collect session-state files */
|
/* collect session-state files */
|
||||||
vector<string> files;
|
|
||||||
do_not_copy_extensions.clear ();
|
do_not_copy_extensions.clear ();
|
||||||
do_not_copy_extensions.push_back (history_suffix);
|
do_not_copy_extensions.push_back (history_suffix);
|
||||||
|
|
||||||
blacklist_dirs.clear ();
|
blacklist_dirs.clear ();
|
||||||
blacklist_dirs.push_back (string (externals_dir_name) + G_DIR_SEPARATOR);
|
blacklist_dirs.push_back (string (externals_dir_name) + G_DIR_SEPARATOR);
|
||||||
|
|
||||||
find_files_matching_filter (files, to_dir, accept_all_files, 0, false, true, true);
|
find_files_matching_filter (extra_files, to_dir, accept_all_files, 0, false, true, true);
|
||||||
for (vector<string>::const_iterator i = files.begin (); i != files.end (); ++i) {
|
for (auto const& from : extra_files) {
|
||||||
std::string from = *i;
|
|
||||||
bool do_copy = true;
|
bool do_copy = true;
|
||||||
for (vector<string>::iterator v = blacklist_dirs.begin(); v != blacklist_dirs.end(); ++v) {
|
for (vector<string>::iterator v = blacklist_dirs.begin(); v != blacklist_dirs.end(); ++v) {
|
||||||
if (from.find (*v) != string::npos) {
|
if (from.find (*v) != string::npos) {
|
||||||
|
|
@ -5902,6 +5913,8 @@ Session::archive_session (const std::string& dest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
/* restore original values */
|
/* restore original values */
|
||||||
_path = old_path;
|
_path = old_path;
|
||||||
_name = old_name;
|
_name = old_name;
|
||||||
|
|
@ -5923,6 +5936,11 @@ Session::archive_session (const std::string& dest,
|
||||||
i->first->set_channel (i->second);
|
i->first->set_channel (i->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (progress && progress->cancelled ()) {
|
||||||
|
remove_directory (to_dir);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int rv = ar.create (filemap, compression_level);
|
int rv = ar.create (filemap, compression_level);
|
||||||
remove_directory (to_dir);
|
remove_directory (to_dir);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue