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

shanjit at seeta.in shanjit at seeta.in
Fri Nov 12 10:50:01 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_1.png, games_2.png. games_3.jpg and so on.
---
 src/jarabe/journal/model.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 81ca7d4..81d1663 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -529,8 +529,8 @@ 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
+        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
             if not os.path.exists(os.path.join(mount_point, file_name)):
                 break
-- 
1.7.2.2



More information about the Sugar-devel mailing list