clean-user-exports: prevent crash when missing directory (#54406)
This commit is contained in:
parent
78b07aa497
commit
434a328bb5
|
@ -27,6 +27,9 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
path = default_storage.path('user_exports')
|
path = default_storage.path('user_exports')
|
||||||
|
if not os.path.exists(path):
|
||||||
|
return
|
||||||
|
|
||||||
for directory in os.listdir(path):
|
for directory in os.listdir(path):
|
||||||
dir_path = os.path.join(path, directory)
|
dir_path = os.path.join(path, directory)
|
||||||
modification_timestamp = os.path.getmtime(dir_path)
|
modification_timestamp = os.path.getmtime(dir_path)
|
||||||
|
|
|
@ -410,6 +410,9 @@ def test_clean_user_exports(settings, app, superuser, freezer):
|
||||||
users = [User(username='user%s' % i) for i in range(10)]
|
users = [User(username='user%s' % i) for i in range(10)]
|
||||||
User.objects.bulk_create(users)
|
User.objects.bulk_create(users)
|
||||||
|
|
||||||
|
# export directory does not exist yet
|
||||||
|
call_command('clean-user-exports')
|
||||||
|
|
||||||
resp = login(app, superuser, '/manage/users/')
|
resp = login(app, superuser, '/manage/users/')
|
||||||
resp = resp.click('CSV').follow()
|
resp = resp.click('CSV').follow()
|
||||||
file_creation_time = now()
|
file_creation_time = now()
|
||||||
|
|
Loading…
Reference in New Issue