Fix bumping .mid file name (snapshots & playlist copy)
When forking regions, copying playlists or saving snapshots we do not have a reference to the track and cannot use the track's name as basis for the new filename like Editor::fork_region() does. A cloned midi region's name is based on the original region name. This prevents endless addition "name-1-1-1-1-1-1-1-1.mid", adding to the region's basename.
This commit is contained in:
parent
40edbb9519
commit
6654c53760
@ -5277,15 +5277,10 @@ Session::new_audio_source_path (const string& base, uint32_t nchan, uint32_t cha
|
|||||||
string
|
string
|
||||||
Session::new_midi_source_path (const string& base, bool need_lock)
|
Session::new_midi_source_path (const string& base, bool need_lock)
|
||||||
{
|
{
|
||||||
uint32_t cnt;
|
|
||||||
char buf[PATH_MAX+1];
|
|
||||||
const uint32_t limit = 10000;
|
|
||||||
string legalized;
|
|
||||||
string possible_path;
|
string possible_path;
|
||||||
string possible_name;
|
string possible_name;
|
||||||
|
|
||||||
buf[0] = '\0';
|
possible_name = legalize_for_path (base);
|
||||||
legalized = legalize_for_path (base);
|
|
||||||
|
|
||||||
// Find a "version" of the file name that doesn't exist in any of the possible directories.
|
// Find a "version" of the file name that doesn't exist in any of the possible directories.
|
||||||
std::vector<string> sdirs = source_search_path(DataType::MIDI);
|
std::vector<string> sdirs = source_search_path(DataType::MIDI);
|
||||||
@ -5300,17 +5295,15 @@ Session::new_midi_source_path (const string& base, bool need_lock)
|
|||||||
*/
|
*/
|
||||||
std::reverse(sdirs.begin(), sdirs.end());
|
std::reverse(sdirs.begin(), sdirs.end());
|
||||||
|
|
||||||
for (cnt = 1; cnt <= limit; ++cnt) {
|
while (true) {
|
||||||
|
possible_name = bump_name_once (possible_name, '-');
|
||||||
|
|
||||||
vector<space_and_path>::iterator i;
|
vector<space_and_path>::iterator i;
|
||||||
uint32_t existing = 0;
|
uint32_t existing = 0;
|
||||||
|
|
||||||
for (vector<string>::const_iterator i = sdirs.begin(); i != sdirs.end(); ++i) {
|
for (vector<string>::const_iterator i = sdirs.begin(); i != sdirs.end(); ++i) {
|
||||||
|
|
||||||
snprintf (buf, sizeof(buf), "%s-%u.mid", legalized.c_str(), cnt);
|
possible_path = Glib::build_filename (*i, possible_name + ".mid");
|
||||||
possible_name = buf;
|
|
||||||
|
|
||||||
possible_path = Glib::build_filename (*i, possible_name);
|
|
||||||
|
|
||||||
if (Glib::file_test (possible_path, Glib::FILE_TEST_EXISTS)) {
|
if (Glib::file_test (possible_path, Glib::FILE_TEST_EXISTS)) {
|
||||||
existing++;
|
existing++;
|
||||||
@ -5321,17 +5314,17 @@ Session::new_midi_source_path (const string& base, bool need_lock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existing == 0) {
|
if (possible_path.size () >= PATH_MAX) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cnt > limit) {
|
|
||||||
error << string_compose(
|
error << string_compose(
|
||||||
_("There are already %1 recordings for %2, which I consider too many."),
|
_("There are already many recordings for %1, resulting in a too long file-path %2."),
|
||||||
limit, base) << endmsg;
|
base, possible_path) << endmsg;
|
||||||
destroy ();
|
destroy ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (existing == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No need to "find best location" for software/app-based RAID, because
|
/* No need to "find best location" for software/app-based RAID, because
|
||||||
|
Loading…
Reference in New Issue
Block a user