Exemplo n.º 1
0
    def link_to_cache(self):
        """Hard-link the cache file into the proper location in the
        pool.
        """

        pexist = os.path.exists
        locations = self.get_links()
        for link_dest, blob_id in locations.items():
            link_src = self.cache.file_path(blob_id)
            if pexist(link_dest):
                if os.path.samefile(link_src, link_dest):
                    continue
                else:
                    message =  ", %s exists and is not %s"  \
                               % (link_dest, link_src)
                    raise IntegrityFault(message)
            link_dest_dir = os.path.dirname(link_dest)
            ensure_directory_exists(link_dest_dir)
            try:
                os.link(link_src, link_dest)
            except OSError, message:
                raise IntegrityFault(
                    "%s: Cannot link %s to %s" \
                    % (message, link_src,link_dest)
                    )
Exemplo n.º 2
0
    def link_to_cache(self):
        """Hard-link the cache file into the proper location in the
        pool.
        """

        pexist = os.path.exists
        locations = self.get_links()
        for link_dest, blob_id in locations.items():
            link_src = self.cache.file_path(blob_id)
            if pexist(link_dest):
                if os.path.samefile(link_src, link_dest):
                    continue
                else:
                    message =  ", %s exists and is not %s"  \
                               % (link_dest, link_src)
                    raise IntegrityFault(message)
            link_dest_dir = os.path.dirname(link_dest)
            ensure_directory_exists(link_dest_dir)
            try:
                os.link(link_src, link_dest)
            except OSError, message:
                raise IntegrityFault(
                    "%s: Cannot link %s to %s" \
                    % (message, link_src,link_dest)
                    )
Exemplo n.º 3
0
    def make_download_filename(self):
        """Create a pathname convenient for creating files for
        later linkage into the cache.
        """

        # mkstemp actually creates the file, so we must enusre this can
        # succeed.
        ensure_directory_exists(self.path)
        temp_fd, temp_fname = mkstemp('.partial', '.', self.path)
        os.close(temp_fd)

        self.umask_permissions(temp_fname)

        return temp_fname
Exemplo n.º 4
0
    def make_download_filename(self):
        """Create a pathname convenient for creating files for
        later linkage into the cache.
        """

        # mkstemp actually creates the file, so we must enusre this can
        # succeed.
        ensure_directory_exists(self.path)
        temp_fd, temp_fname = mkstemp('.partial', '.', self.path)
        os.close(temp_fd)

        self.umask_permissions(temp_fname)

        return temp_fname
Exemplo n.º 5
0
 def __init__(self, cache_path):
     SimpleCache.__init__(self, cache_path)
     ensure_directory_exists(self.path)
Exemplo n.º 6
0
 def __init__(self, cache_path):
     SimpleCache.__init__(self, cache_path)
     ensure_directory_exists(self.path)