Django

Code

Ticket #8203: patch-#8203.diff

File patch-#8203.diff, 0.7 kB (added by rajeshdhawan, 2 years ago)

Revised patch that closes the temporary file only on Windows leaving the behaviour on other OSes unchanged.

  • django/core/files/storage.py

    old new  
    146146            try: 
    147147                # This file has a file path that we can move. 
    148148                if hasattr(content, 'temporary_file_path'): 
     149                    if os.name == 'nt': 
     150                        # If the temporary file is not closed on Windows,  
     151                        # file_move_safe will fail. 
     152                        content.close() 
    149153                    file_move_safe(content.temporary_file_path(), full_path) 
    150154                    content.close() 
    151155