OwlCyberSecurity - MANAGER
Edit File: move.cpython-39.pyc
a kH�f� � @ sD d Z ddlZddlmZmZ ddlmZ dgZdd� Zdd d�Z dS )z� Move a file in the safest way possible:: >>> from django.core.files.move import file_move_safe >>> file_move_safe("/tmp/old_file", "/tmp/new_file") � N)�copymode�copystat)�locks�file_move_safec C sZ t tjd�r2ztj�| |�W S ty0 Y dS 0 tj�tj�| ��tj�tj�|��kS )N�samefileF)�hasattr�os�pathr �OSError�normcase�abspath)�src�dst� r �X/home/gouroczh/virtualenv/test/3.9/lib/python3.9/site-packages/django/core/files/move.py� _samefile s �r � Fc C s� t | |�rdS z0|s.t�|tj�r.td| ��t�| |� W dS tyP Y n0 t| d���}t�|tjtj B t tdd�B |s�tjndB �}zJt� |tj� d}|dkr�|�|�}t�||� q�W t�|� t�|� nt�|� t�|� 0 W d � n1 �s0 Y zt| |� W n8 t�yT zt| |� W n t�yN Y n0 Y n0 zt�| � W n: t�y� } z t |dd�dk�r�� W Y d}~n d}~0 0 dS ) aU Move a file from one location to another in the safest way possible. First, try ``os.rename``, which is simple but will break across filesystems. If that fails, stream manually from one file to another in pure Python. If the destination file exists and ``allow_overwrite`` is ``False``, raise ``FileExistsError``. Nz8Destination file %s exists and allow_overwrite is False.�rb�O_BINARYr � �winerror� )r r �access�F_OK�FileExistsError�renamer �open�O_WRONLY�O_CREAT�getattr�O_EXCLr �lockZLOCK_EX�read�write�unlock�closer �PermissionErrorr �remove)Z old_file_nameZ new_file_name� chunk_sizeZallow_overwriteZold_file�fdZ current_chunk�er r r r s\ ��� ��� � ,)r F) �__doc__r �shutilr r Zdjango.core.filesr �__all__r r r r r r �<module> s �