diff options
author | Robin Gareus <robin@gareus.org> | 2015-09-10 00:48:10 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2015-09-10 00:55:58 +0200 |
commit | 390ea007c5b6b647e33c924b3429bf49ae83b1ca (patch) | |
tree | 774a07a6132c8c211de95e43a53484be5007ddbf /libs/ardour/session.cc | |
parent | 78ff3c05a3f5c5d532162b45bdd8857bc402011e (diff) |
rework peakfile handling:
- copy old peak-files to new (do not require re-calc)
- keep old peak-files (for now, backwards compat)
- fix cleanup-sources to remove *new* peak-file
- include channel-number in hash (like it was done before)
see also 624f76b
TODO: add Session > Cleanup > remove/re-create peaks
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r-- | libs/ardour/session.cc | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index f8bd39fe33..30ab5e1660 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4363,8 +4363,18 @@ Session::count_sources_by_origin (const string& path) return cnt; } +static string +peak_file_helper (const string& peak_path, const string& file_path, const string& file_base, bool hash) { + if (hash) { + std::string checksum = Glib::Checksum::compute_checksum(Glib::Checksum::CHECKSUM_SHA1, file_path + G_DIR_SEPARATOR + file_base); + return Glib::build_filename (peak_path, checksum + peakfile_suffix); + } else { + return Glib::build_filename (peak_path, file_base + peakfile_suffix); + } +} + string -Session::construct_peak_filepath (const string& filepath) const +Session::construct_peak_filepath (const string& filepath, bool oldformat) const { string interchange_dir_string = string (interchange_dir_name) + G_DIR_SEPARATOR; @@ -4397,24 +4407,25 @@ Session::construct_peak_filepath (const string& filepath) const if (in_another_session) { SessionDirectory sd (session_path); - return Glib::build_filename (sd.peak_path(), Glib::path_get_basename (filepath) + peakfile_suffix); + return peak_file_helper (sd.peak_path(), "", Glib::path_get_basename (filepath), !oldformat); } } + /* 1) if file belongs to this session + * it may be a relative path (interchange/...) + * or just basename (session_state, remove source) + * -> just use the basename + */ std::string filename = Glib::path_get_basename (filepath); std::string path; - /* file is within our session: just use the filename for checksumming and leave path empty */ + /* 2) if the file is outside our session dir: + * (imported but not copied) add the path for check-summming */ if (filepath.find (interchange_dir_string) == string::npos) { - /* the file is outside our session: add the filepath for checksummming */ path = Glib::path_get_dirname (filepath); } - string::size_type suffix = filename.find_last_of ('.'); - - std::string checksum = Glib::Checksum::compute_checksum(Glib::Checksum::CHECKSUM_SHA1, path + G_DIR_SEPARATOR + filename); - - return Glib::build_filename (_session_dir->peak_path(), checksum + peakfile_suffix); + return peak_file_helper (_session_dir->peak_path(), path, Glib::path_get_basename (filepath), !oldformat); } string |