³ò
OÉcIc           @   s¼   d  Z  d d k l Z d d k Z d d k Z d d k Z d d k Z d d k Z d a	 d „  Z
 d „  Z d „  Z d d „ Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d d „ Z d S(   sÑ  Preserve and restore hard links

If the preserve_hardlinks option is selected, linked files in the
source directory will be linked in the mirror directory.  Linked files
are treated like any other with respect to incrementing, but their
link status can be retrieved because their device location and inode #
is written in the metadata file.

All these functions are meant to be executed on the mirror side.  The
source side should only transmit inode information.

iÿÿÿÿ(   t
   generatorsNc           C   s
   h  a  d S(   s+   Set all the hard link dictionaries to emptyN(   t   _inode_index(    (    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   initialize_dictionaries-   s    c           C   s
   d a d S(   s   Delete all dictionariesN(   t   NoneR   (    (    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   clear_dictionaries2   s    c         C   s   |  i  ƒ  |  i ƒ  f S(   s*   Return rorp's key for _inode_ dictionaries(   t   getinodet	   getdevloc(   t   rorp(    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   get_inode_key7   s    c         C   sÆ   |  i  ƒ  p |  i ƒ  d j  o d Sn t |  ƒ } t i | ƒ p} | p
 d } n* | i ƒ  d j o
 d } n t | ƒ } |  i ƒ  o |  i ƒ  p d } |  i |  i ƒ  | | f t | <n | S(   s2   Process new rorp and update hard link dictionariesi   i   t   NAN(	   t   isregt   getnumlinksR   R   R   t   has_keyt   has_sha1t   get_sha1t   index(   R   t	   dest_rorpt   rp_inode_keyt   dest_keyt   digest(    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   add_rorp;   s    !  
 
 c         C   s£   |  i  ƒ  p |  i ƒ  d j  o d Sn t |  ƒ } t i | ƒ } | p d Sn | \ } } } } | d j o t | =d Sn | | d | | f t | <d Sd S(   s9   Remove rorp information from dictionary if seen all linksi   Ni   i    (   R
   R   R   R   t   get(   R   R   t   valR   t	   remainingR   R   (    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   del_rorpH   s    !  c         C   sî   |  i  ƒ  p8 | i  ƒ  p* |  i ƒ  | i ƒ  j o
 d j n o d Sn |  i ƒ  | i ƒ  j  o d Sn t |  ƒ } t | \ } } } } | d j o | | d d f t | <d Sn y | t | ƒ j SWn t j
 o d Sn Xd S(   sº   Compare hardlinked for equality

	Return false if dest_rorp is linked differently, which can happen
	if dest is linked more than source, or if it is represented by a
	different inode.

	i   i    R	   N(   R
   R   R   R   R   t   KeyError(   t   src_rorpR   t   src_keyR   R   R   R   (    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   rorp_eqV   s    * c         C   sP   |  i  ƒ  d j p d Sn t i t |  ƒ ƒ } | p d Sn | d |  i j S(   s?   True if rorp's index is already linked to something on src sidei   i    (   R   R   R   R   R   (   R   t   dict_val(    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   islinkedo   s      c         C   s   t  t |  ƒ d S(   s;   Return first index on target side rorp is already linked toi    (   R   R   (   R   (    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   get_link_indexv   s    c         C   s   t  t |  ƒ d S(   s,   Return sha1 digest of what rorp is linked toi   (   R   R   (   R   (    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyR   z   s    c         C   s›   | p
 | } n | i  |  i ƒ  ƒ } y | i | i ƒ WnZ t j
 oN } t i | d d j o | i ƒ  q— t d | | i | i f ƒ ‚ n Xd S(   s8   Make dest_rpath into a link using link flag in diff_rorpi    t   ENOENTs&   EnvironmentError '%s' linking %s to %sN(	   t	   new_indext   get_link_flagt   hardlinkt   patht   EnvironmentErrort   errnot	   errorcodet   toucht	   Exception(   t	   diff_rorpt
   dest_rpatht	   dest_roott   dest_link_rpatht   exc(    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pyt   link_rp~   s     
 (   t   __doc__t
   __future__R    t   Globalst   Timet   logt   robustR&   R   R   R   R   R   R   R   R   R   R   R   R/   (    (    (    s:   /var/lib/python-support/python2.5/rdiff_backup/Hardlink.pys   <module>   s   <									