﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23986	Collectstatic --clear fails if the static dir doesn't exist yet	Michael	Sztrovacsek	"The --clear flag on collectstatic fails if the target directory doesn't exist yet.

{{{
Traceback (most recent call last):
  File ""redacted/bin/manage.py"", line 16, in <module>
    execute_from_command_line(sys.argv)
  File ""redacted/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 385, in execute_from_command_line
    utility.execute()
  File ""redacted/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""redacted/local/lib/python2.7/site-packages/django/core/management/base.py"", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""redacted/local/lib/python2.7/site-packages/django/core/management/base.py"", line 338, in execute
    output = self.handle(*args, **options)
  File ""redacted/local/lib/python2.7/site-packages/django/core/management/base.py"", line 533, in handle
    return self.handle_noargs(**options)
  File ""redacted/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py"", line 168, in handle_noargs
    collected = self.collect()
  File ""redacted/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py"", line 89, in collect
    self.clear_dir('')
  File ""redacted/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py"", line 202, in clear_dir
    dirs, files = self.storage.listdir(path)
  File ""redacted/local/lib/python2.7/site-packages/django/core/files/storage.py"", line 270, in listdir
    for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/redacted/public/static/2.1.0-dev'

}}}


Adding 
{{{
        if not os.path.exists(self.storage.location):
            return
}}}

In Command.clear_dir() fixes the issue"	Bug	closed	contrib.staticfiles	1.7	Normal	fixed			Ready for checkin	1	0	0	0	1	0
