]> git.parisson.com Git - teleforma.git/commitdiff
fix long filename
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 1 Aug 2014 09:56:48 +0000 (11:56 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 1 Aug 2014 09:56:48 +0000 (11:56 +0200)
teleforma/exam/models.py

index 4dc437f662f57050a93f93e070be67263fed9afd..9f603852ce7293e740d27b95d2da5e56fbdae2f5 100644 (file)
@@ -301,11 +301,13 @@ class Script(BaseResource):
         new_rel = os.sep.join(old_rel_root) + os.sep + slugify(filename) + ext
 
         if os.path.exists(new_abs):
-             new_abs = os.sep.join(old_abs_root) + os.sep + slugify(filename) + '_' + unicode(self.uuid) + ext
-             new_rel = os.sep.join(old_rel_root) + os.sep + slugify(filename) + '_' + unicode(self.uuid) + ext
+             new_abs = os.sep.join(old_abs_root) + os.sep + unicode(self.uuid) + ext
+             new_rel = os.sep.join(old_rel_root) + os.sep + unicode(self.uuid) + ext
+
+        if not os.path.exists(new_abs):
+            os.rename(old_abs, new_abs)
+            self.file = new_rel
 
-        os.rename(old_abs, new_abs)
-        self.file = new_rel
         self.save()
 
     def box_upload(self):