# HG changeset patch # User dellsystem # Date 1361256839 18000 # Node ID 95edf106bdeff45ce38fe62f7df00f5105d7958c # Parent 4033ebe1867fd1e7936ff2c516fb28befca01fb5 Create BundleVersion when uploading text bundles Forgot to add that earlier diff -r 4033ebe1867f -r 95edf106bdef apps/bundle/tasks.py --- 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()