Projet

Général

Profil

0001-clean-user-exports-prevent-crash-when-missing-direct.patch

Valentin Deniaud, 31 mai 2021 17:57

Télécharger (1,58 ko)

Voir les différences:

Subject: [PATCH] clean-user-exports: prevent crash when missing directory
 (#54406)

 src/authentic2/management/commands/clean-user-exports.py | 3 +++
 tests/test_commands.py                                   | 3 +++
 2 files changed, 6 insertions(+)
src/authentic2/management/commands/clean-user-exports.py
27 27

  
28 28
    def handle(self, **options):
29 29
        path = default_storage.path('user_exports')
30
        if not os.path.exists(path):
31
            return
32

  
30 33
        for directory in os.listdir(path):
31 34
            dir_path = os.path.join(path, directory)
32 35
            modification_timestamp = os.path.getmtime(dir_path)
tests/test_commands.py
410 410
    users = [User(username='user%s' % i) for i in range(10)]
411 411
    User.objects.bulk_create(users)
412 412

  
413
    # export directory does not exist yet
414
    call_command('clean-user-exports')
415

  
413 416
    resp = login(app, superuser, '/manage/users/')
414 417
    resp = resp.click('CSV').follow()
415 418
    file_creation_time = now()
416
-