changeset 210:95edf106bdef

Create BundleVersion when uploading text bundles Forgot to add that earlier
author dellsystem <ilostwaldo@gmail.com>
date Tue, 19 Feb 2013 01:53:59 -0500
parents 4033ebe1867f
children 2a234e11185c
files apps/bundle/tasks.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/apps/bundle/tasks.py	Sun Feb 17 14:57:39 2013 -0500
+++ b/apps/bundle/tasks.py	Tue Feb 19 01:53:59 2013 -0500
@@ -74,14 +74,12 @@
 
     if extension in archive_extensions:
         new_path = file + extension
+        # Save the new file name (needed for the BundleVersion)
+
+        new_file_name = os.path.basename(new_path)
         # Treat it as an archive. Rename it to that, then extract
         os.rename(file, new_path)
 
-        # Create the new BundleVersion
-        new_file_name = os.path.basename(new_path)
-        BundleVersion.objects.create(bundle=bundle, file_name=new_file_name,
-            version=bundle.latest_version)
-
         try:
             # Extract it to a directory, same path as the filename
             archive.extract(new_path, to_path=file)
@@ -97,6 +95,11 @@
             version=bundle.latest_version)
         bundle_file.save_file_contents(open(file, 'rt'),
             original_filename=bundle.file_name)
+        new_file_name = os.path.basename(file)
+
+    # Create the new BundleVersion
+    BundleVersion.objects.create(bundle=bundle, file_name=new_file_name,
+        version=bundle.latest_version)
 
     bundle.done_uploading = True
     bundle.save()