Update the target file name after transcoding

After a transcoding job is complete, we need to update the corresponding
filename since the transcoder, rather than overwriting an existing file,
changes the filename of the output file. This ensures that the right
file is tagged later on.
This commit is contained in:
Mattias Andersson 2015-02-18 22:58:45 +01:00
parent 7d0d7be568
commit f7185101ce
2 changed files with 14 additions and 2 deletions

View File

@ -135,6 +135,16 @@ void Ripper::TranscodingJobComplete(const QString& input, const QString& output,
bool success) {
(*(success ? &finished_success_ : &finished_failed_))++;
UpdateProgress();
// The the transcoder does not overwrite files. Instead, it changes
// the name of the output file. We need to update the transcoded
// filename for the corresponding track so that we tag the correct
// file later on.
for (TrackInformation& track : tracks_) {
if (track.temporary_filename == input) {
track.transcoded_filename = output;
}
}
}
void Ripper::AllTranscodingJobsComplete() {
@ -199,7 +209,7 @@ void Ripper::Rip() {
// Set up progress bar
UpdateProgress();
for (const TrackInformation& track : tracks_) {
for (TrackInformation& track : tracks_) {
QString filename =
QString("%1%2.wav").arg(temporary_directory_).arg(track.track_number);
QFile destination_file(filename);
@ -231,7 +241,8 @@ void Ripper::Rip() {
finished_success_++;
UpdateProgress();
transcoder_->AddJob(filename, track.preset, track.transcoded_filename);
track.temporary_filename = filename;
transcoder_->AddJob(track.temporary_filename, track.preset, track.transcoded_filename);
}
emit(RippingComplete());
}

View File

@ -96,6 +96,7 @@ signals:
QString title;
QString transcoded_filename;
TranscoderPreset preset;
QString temporary_filename;
};
struct AlbumInformation {