Django

Code

Ticket #8455: issue-8455.diff

File issue-8455.diff, 0.9 kB (added by carljm, 5 months ago)

patch to check OSError error number

  • django/core/files/storage.py

    old new  
    161161                    finally: 
    162162                        locks.unlock(fd) 
    163163                        os.close(fd) 
    164             except OSError: 
    165                 # Ooops, we need a new file name. 
    166                 name = self.get_available_name(name) 
    167                 full_path = self.path(name) 
     164            except OSError, e: 
     165                # error number 17 is 'File exists' 
     166                if e.errno == 17: 
     167                    # Ooops, we need a new file name. 
     168                    name = self.get_available_name(name) 
     169                    full_path = self.path(name) 
     170                else: 
     171                    raise 
    168172            else: 
    169173                # OK, the file save worked. Break out of the loop. 
    170174                break