Bug 119656 - "Encode File" dialog deletes files on error without any user request
Summary: "Encode File" dialog deletes files on error without any user request
Status: RESOLVED FIXED
Alias: None
Product: kaudiocreator
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR major
Target Milestone: ---
Assignee: Gerd Fleischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-07 00:26 UTC by Christian Schuerer
Modified: 2006-11-06 18:29 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schuerer 2006-01-07 00:26:41 UTC
Version:           1.13 (using KDE KDE 3.5.0)
Installed from:    Debian testing/unstable Packages
OS:                Linux

I wanted to encode an existing wav-file into mp3 with the "Encode File" dialog. I selected a file and entered a title but didn't fill out the other fields as it was a short jingle-file. When I started encoding of the file, I got an error message saying:

"The encoded file was not created.
Please check the encoder options.
The wav file has been removed.
Do you want to see the full encoder output?"

The problem was, that lame didn't like the default genre "Unknown". This shouldn't be a problem to solve -- but more severe is, that the wav-file was DELETED!

If this wav-file would just have been a rip of an CD, it wouldn't be any problem. But this wav-file is now lost without any chance to recover it.

Please fix this bug, so that file don't get deleted due some errors but the encoder.
Comment 1 David P James 2006-01-13 00:57:33 UTC
I can confirm this on the same platform (well, Debian Sid anyway).

The problem seems to be more generalized than the foregoing however. Even from CD, with a genre entry, KAudiocreator is deleting the ripped .wav before it can encode it into ogg or anything else. The upshot is that KAudiocreator is not useful at all at present.
Comment 2 S. Burmeister 2006-03-29 17:37:48 UTC
I just had some data-loss because of this bug too! Is this fixed in 3.5.2? Loosing data is a serious issue!

Minimum expected behaviour would be to only delete files that were created by the app itself. More sensible would be to keep the file until the user wants to delete it, or the encoding was successful.
Comment 3 Richard Lärkäng 2006-11-06 18:29:22 UTC
SVN commit 602728 by larkang:

Replace '~' by homedir-path before doing the filename expansion
Don't the wav-files when using "Encode File"

BUG: 115217
BUG: 119656


 M  +2 -0      encodefileimp.cpp  
 M  +4 -4      encoder.cpp  
 M  +4 -1      job.h  


--- branches/KDE/3.5/kdemultimedia/kaudiocreator/encodefileimp.cpp #602727:602728
@@ -62,6 +62,8 @@
   newJob->track_artist = track_artist->text();
   newJob->track_comment = track_comment->text();
 
+  newJob->removeTempFile = false;
+
   emit(startJob(newJob));
 
   // Same message and *strings* from tracksimp.cpp
--- branches/KDE/3.5/kdemultimedia/kaudiocreator/encoder.cpp #602727:602728
@@ -159,6 +159,7 @@
 	}
 	
 	QString desiredFile = Prefs::fileFormat();
+	desiredFile.replace( QRegExp("~"), QDir::homeDirPath() );
 	{
 		QMap <QString,QString> map;
 		map.insert("extension", prefs->extension());
@@ -167,7 +168,6 @@
 		jobx.fix("/", "%2f");
 		// If the user wants anything regexp replaced do it now...
 		desiredFile = jobx.replaceSpecialChars(desiredFile, false, map);
-		desiredFile.replace( QRegExp("~"), QDir::homeDirPath() );
 	}
 
 	while ( QFile::exists( desiredFile ) ) {
@@ -284,12 +284,10 @@
 	bool showDebugBox = false;
 	if ( process->exitStatus() == 127 ) {
 		KMessageBox::sorry(0, i18n("The selected encoder was not found.\nThe wav file has been removed. Command was: %1").arg(job->errorString), i18n("Encoding Failed"));
-		QFile::remove(job->location);
 		emit(updateProgress(job->id, -1));
 	}
 	else if ( QFile::exists(job->newLocation) ) {
 		emit(jobIsDone(job, prefs->extension()));
-		QFile::remove(job->location);
 
 		// fyi segfaults return 136
 		if ( process->exitStatus() != 0 ) {
@@ -312,10 +310,12 @@
 		{
 			showDebugBox = true;
 		}
-		QFile::remove( job->location );
 		emit( updateProgress( job->id, -1 ) );
 	}
 
+	if ( job->removeTempFile )
+		QFile::remove( job->location );
+
 	if( showDebugBox ){
 		EncoderOutput dlg( 0, "Encoder Output" );
 		job->output = job->errorString + "\n\n\n" + job->output;
--- branches/KDE/3.5/kdemultimedia/kaudiocreator/job.h #602727:602728
@@ -31,7 +31,7 @@
 class Job{
 
 public:
-	inline Job():id(-1),track_title(""),track_artist(""), track(-1),track_comment(""), year(-1), genre(i18n("Other")), group(""), album(""), comment(""), lastSongInAlbum(false), encoder(-1) {};
+	inline Job():id(-1),track_title(""),track_artist(""), track(-1),track_comment(""), year(-1), genre(i18n("Other")), group(""), album(""), comment(""), lastSongInAlbum(false), removeTempFile(true), encoder(-1) {};
 
 	QString replaceSpecialChars(const QString &string, bool quote, QMap<QString,QString> map);
 
@@ -65,6 +65,9 @@
 	// If this is the last track to be ripped then value is true. 
 	bool lastSongInAlbum;
 
+	// If the file should be removed when finished encoding
+	bool removeTempFile;
+
 	// output from the processing.
 	QString output;