[banshee/stable-1.8] [AudioCdRipper] Don't overwrite existing files when ripping (bgo#540394)



commit a21d796e0c3874444fa03f794788678c9b24ed16
Author: Olivier Dufour <olivier duff gmail com>
Date:   Fri Nov 5 18:18:50 2010 +0100

    [AudioCdRipper] Don't overwrite existing files when ripping (bgo#540394)
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 .../Banshee.GStreamer/AudioCdRipper.cs             |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs
index a9fd24a..d5d2dcc 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs
@@ -142,6 +142,13 @@ namespace Banshee.GStreamer
 
             using (TagList tags = new TagList (track)) {
                 output_path = String.Format ("{0}.{1}", outputUri.LocalPath, output_extension);
+
+                // Avoid overwriting an existing file
+                int i = 1;
+                while (Banshee.IO.File.Exists (new SafeUri (output_path))) {
+                    output_path = String.Format ("{0} ({1}).{2}", outputUri.LocalPath, i++, output_extension);
+                }
+
                 Log.DebugFormat ("GStreamer ripping track {0} to {1}", trackIndex, output_path);
 
                 br_rip_track (handle, trackIndex + 1, output_path, tags.Handle, out taggingSupported);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]