def link_files(self, destination_path, files):
        """
        Links the files to the destination_path if they are found.
        """
        if not os.path.isdir(destination_path):
            os.makedirs(destination_path)
        
        for f in files:
            if f['completed']:
                destination = os.path.join(destination_path, *f['path'])
                
                file_path = os.path.dirname(destination)
                if not os.path.isdir(file_path):
                    logger.debug('Folder %r does not exist, creating' % file_path)
                    os.makedirs(file_path)
    
                logger.debug('Making %s link from %r to %r' % (self.link_type, f['actual_path'], destination))
                
                if self.link_type == 'soft':
                    os.symlink(f['actual_path'], destination)
                elif self.link_type == 'hard':
                    os.link(f['actual_path'], destination)
                else:
                    raise UnknownLinkTypeException('%r is not a known link type' % self.link_type)
dataset/ETHPy150Open JohnDoee/autotorrent/autotorrent/at.py/AutoTorrent.link_files/original