Converting things with same filename at the same time doesn't work

Bug #1357597 reported by Evert Van Petegem on 2014-08-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SoundConverter
Critical
GautierPortet

Bug Description

So, real world example first. I was trying to convert all the music of one artist at the same time. The problem arose when the first track on an EP was also the first track on an album. Because the two files were to be converted at the same time the name of the temporary file was the same for both. This made it give the following error:

GStreamer Error:
Could not open resource for writing.
<filename>

An easy fix would seem to me to attach a random string at the end of the temporary file. The following diff (against the 2.1.3 tree) fixed the problem for me.

@@ -21,6 +21,7 @@

 import os
 import sys
+from random import random
 from urlparse import urlparse
 from gettext import gettext as _

@@ -688,7 +689,7 @@ class ConverterQueue(TaskQueue):

     def add(self, sound_file):
         # generate a temporary filename from source name and output suffix
- output_filename = self.window.prefs.generate_temp_filename(sound_file) + '~SC~'
+ output_filename = self.window.prefs.generate_temp_filename(sound_file) + str(random()) + '~SC~'

         if vfs_exists(output_filename):
             # always overwrite temporary files

Michael Schwendt (mschwendt) wrote :

Raises the question whether generate_temp_filename() should return unique file names to begin with, instead of appending a random string anywhere the function is reused?

Changed in soundconverter:
assignee: nobody → GautierPortet (kassoulet)
milestone: none → 3.0
milestone: 3.0 → 2.1.4
importance: Undecided → Critical
status: New → Confirmed
GautierPortet (kassoulet) wrote :
Changed in soundconverter:
status: Confirmed → Fix Committed
Changed in soundconverter:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers