[Sugar-devel] [PATCH] Copying files multiple times results in bogus names. (SL#2060)

shanjit at seeta.in shanjit at seeta.in
Wed Nov 10 06:54:11 EST 2010


From: Shanjit Singh Jajmann <shanjit at seeta.in>

For every existing file copied to the location, the names are explicitly changed to filename(copynumber). e.g. games.png, games(2).png. games(3).jpg and so on.
---
 src/jarabe/journal/model.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 81ca7d4..f944a63 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -528,10 +528,10 @@ def _get_file_name(title, mime_type):
 
 def _get_unique_file_name(mount_point, file_name):
     if os.path.exists(os.path.join(mount_point, file_name)):
-        i = 1
+        i = 2
+        name, extension = os.path.splitext(file_name)
         while len(file_name) <= 255:
-            name, extension = os.path.splitext(file_name)
-            file_name = name + '_' + str(i) + extension
+            file_name = name + '(' + str(i) + ')' + extension
             if not os.path.exists(os.path.join(mount_point, file_name)):
                 break
             i += 1
-- 
1.7.2.2



More information about the Sugar-devel mailing list