�
I�g% � � � d Z ddlZddlZddlZddlZddlZddlmZ e n
# e $ r e
ZY nw xY wd� Zd� Zd� Z
dZdZdd �Zd
d�ZdS )z
Disk management utilities.
� N)�utilc �& � d}t j | � � dgz D ]e}t j t j � | |� � � � }t |d� � r||j dz z
}�R||j dz dz dz z
}�ft |dz � � S )z& Return the disk usage in a directory.r �.� st_blocksi � g �@) �os�listdir�stat�path�join�hasattrr �st_size�int)r �size�filer
s �[/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/joblib/disk.py� disk_usedr s� � ��D��
�4� � �C�5�(� 4� 4���w�r�w�|�|�D�$�/�/�0�0���4��%�%� 4��D�N�S�(�(�D�D�
�T�\�S�(�1�,��3�3�D�D� �t�e�|���� c � � d}t ||dz |dz �� � } t || d t | dd� � � z � � }n=# t t f$ r)}t d| �dt | � � �d �� � |�d}~ww xY w|S )
z2 Convert a memory text to its value in bytes.
i � � )�K�M�G�����NzInvalid literal for size give: z (type z') should be alike '10G', '500M', '50K'.)�dictr �float�KeyError�
ValueError�type)�text�kilo�unitsr �es r �memstr_to_bytesr% * s� � � �D��4�4�1�9��� �2�2�2�E�G��5��b��?�U�4����9�%5�%5�5�6�6�����j�!� G� G� G��j�-1�T�T�4��:�:�:�:�
?�@� @�EF� G�����G���� �Ks �3A �B
�!$B�B
c � � t j | � � dS # t $ r!}|j t j k r� Y d}~dS d}~ww xY w)zgEnsure directory d exists (like mkdir -p on Unix)
No guarantee that the directory is writable.
N)r �makedirs�OSError�errno�EEXIST)�dr$ s r �mkdirpr, 8 s] � ��
��A�������� � � ��7�e�l�"�"�� #�"�"�"�"�"��������s � �
A�>�Ag�������?�
c �$ � g } t j | � � }nA# t j $ r/ |�) |t j | t j � � � � n� Y nw xY w|D ]3}t j � | |� � }t ||�� � �4dS )a� Remove all subdirectories in this path.
The directory indicated by `path` is left in place, and its subdirectories
are erased.
If onerror is set, it is called to handle the error with arguments (func,
path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
path is the argument to that function that caused it to fail; and
exc_info is a tuple returned by sys.exc_info(). If onerror is None,
an exception is raised.
N)�onerror)r r �error�sys�exc_infor r �
delete_folder)r r/ �names�name�fullnames r �
rm_subdirsr7 K s� � �
�E���
�4� � ����
�8� � � ����G�B�J��c�l�n�n�5�5�5�5��
6�5����� � 1� 1���7�<�<��d�+�+���h��0�0�0�0�0�1� 1s � �;A�ATc �6 � t j � | � � r�|�t j | d|� � dS d} t j | � � } t
|� � dk s|r@t j | dd�� � t j d� | � � � � dS t d� | t
|� � � � � � �# t t f$ r |dz
}|t k r� Y nw xY wt j t � � ��dS ) zBUtility function to cleanup a temporary folder if it still exists.NFr T)�
ignore_errorsr/ zSuccessfully deleted {}z*Expected empty folder {} but got {} files.r )r r �isdir�shutil�rmtreer �lenr �debug�formatr( �WindowsError�RM_SUBDIRS_N_RETRY�time�sleep�RM_SUBDIRS_RETRY_TIME)�folder_pathr/ �allow_non_empty� err_count�filess r r3 r3 i sL � � �w�}�}�[�!�!� 2����M�+�u�g�6�6�6�6�6� �I�
2��
�;�/�/����5�z�z�Q���/���
�'�u�d�� � � � �
�5�<�<�[�I�I�K� K� K���%�%�%+�V�K��U���%D�%D�� � �� ��.� � � ���N�I� �#5�5�5� � 6�5����� �
�0�1�1�1�-
2�2� 2s �AC �'0C �"C<�;C<)N)NT)�__doc__r r1 rB r) r; �multiprocessingr r@ � NameErrorr( r r% r, rD rA r7 r3 � r r �<module>rM s� ��� �
� � � �
�
�
�
� ���� ����
�
�
�
� � � � � � ���L�L��� � � ��L�L�L�����
�
�
� � � �� � � � �� �1� 1� 1� 1�<2� 2� 2� 2� 2� 2s �! �+�+