[Dextrose] [PATCH V3] Copying files multiple times results in bogus names. (SL#2060)

shanjit at seeta.in shanjit at seeta.in
Sat Nov 13 06:41:03 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.extension e.g. games_1.png, games_2.png,
games_3.jpg and so on.

---
v1 -> v2. Parenthesis idea removed, i initialised from 1.
Recommendations by Gonzalo Odiard, James Cameron and Martin Dengler added.
v2 -> v3. Line wrapping and .extension added.  
---
 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 Dextrose mailing list