#22681 closed Bug (fixed)

TarArchive has_leading_dir usage bug

Reported by: phpdude Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Normal Keywords: startproject, tar, template, allversions
Cc: ya@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I found small bug in django.utils.archive.TarArchive.extract function.

https://github.com/django/django/blob/master/django/utils/archive.py#L147

There members is a list of TarInfo objects (tarfile.TarInfo), not just a list of path strings.

Because of this bug django cannot recognize leading_dir in tar archives.

Take a look for example startproject with tar and zip archive.

(env)@dude /WWW# django-admin.py startproject -v 3 --template http://git.floraconcierge.com/flora-concierge/django-skeleton/repository/archive test14
Rendering project template files with extensions: .py
Rendering project template files with filenames: 
Downloading http://git.floraconcierge.com/flora-concierge/django-skeleton/repository/archive
Extracting /var/folders/7h/k___h29d15n7n5zxqk5l8ktw0000gn/T/django_project_template_FAMd_4_download/django-skeleton-f85cd58a98dd98bd22b56a82a35b3947ad7c7d79.tar.gz

Creating /WWW/test14/django-skeleton.git/manage.py
Creating /WWW/test14/django-skeleton.git/README
Creating /WWW/test14/django-skeleton.git/test14/__init__.py
Creating /WWW/test14/django-skeleton.git/test14/urls.py
Creating /WWW/test14/django-skeleton.git/test14/wsgi.py
...

And example with zip archive

(env)@dude /WWW# django-admin.py startproject -v 3 --template https://github.com/rdegges/django-skel/zipball/master test15
Rendering project template files with extensions: .py
Rendering project template files with filenames: 
Downloading https://github.com/rdegges/django-skel/zipball/master
Extracting /var/folders/7h/k___h29d15n7n5zxqk5l8ktw0000gn/T/django_project_template_DLsbG8_download/rdegges-django-skel-d4631bb.zip

Creating /WWW/test15/.gitignore
Creating /WWW/test15/fabfile.py
Creating /WWW/test15/gunicorn.py.ini
Creating /WWW/test15/manage.py
Creating /WWW/test15/Procfile
Creating /WWW/test15/README.md
Creating /WWW/test15/requirements.txt
Creating /WWW/test15/runtime.txt
Creating /WWW/test15/wsgi.py

I fixed this and created pull request in github. Please aply it soon.

https://github.com/django/django/pull/2701

Thank you, alex

Change History (4)

comment:1 Changed 15 months ago by claudep

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 15 months ago by phpdude

  • Triage Stage changed from Accepted to Ready for checkin

comment:3 Changed 15 months ago by phpdude

Tests fixed. Branch rebased and commit message changed to right one. Please check again.

comment:4 Changed 15 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 083d285b82832f95b57c64144020cc2ce8895a22:

Fixed #22681 -- Made TarArchive recognize leading directories properly.

Note: See TracTickets for help on using tickets.
Back to Top