Danek Duvall wrote:
> On Mon, Jun 23, 2008 at 10:21:47AM -0500, Tom Mueller (pkg-discuss) wrote:
>
>   
>> http://cr.opensolaris.org/~tmueller/cr-954-2/
>>     
>
> Why does get_trashdir() always overwrite cached_image?  Isn't the point of
> having the cached image to not have to run find_root() every time you want
> to move something into the trash?
>   
Good point.  There is a potentially needless find_root for renames that 
go through the exception path.  However, the number of times through the 
exception path is expected to be quite small as there are only a few 
files that are typically being executed.

However the real purpose of the cached image is to avoid having to do a 
find_root on every rename, especially those that don't go through the 
exception path.  So the cached image comes into play in empty_trash 
because that is called on every rename.

I changed get_trashdir as follows (added an if to check if the 
cached_image is suitable)

def get_trashdir(path):
        """
        Use path to determine its image, and return the directory name of
        the trash directory within that image. This method does not create
        the directory. If path is not contained within an image, return 
None.
        The image is cached in the module variable cached_image.
        """
        import pkg.client.image as image
        global cached_image   
        if not cached_image or not path.startswith(cached_image.get_root()):
                cached_image = image.Image()
                try:
                        cached_image.find_root(os.path.dirname(path))
                except ValueError:
                        # if path is not within an image, revert to the
                        # initial state
                        cached_image = None
                        return None
        trashdir = os.path.join(cached_image.imgdir, trashname)
        return trashdir

> I'm also wondering how often you'll be dealing with multiple images in a
> single process, or if the support for that is just belt+suspenders+bodycondom.
>   
The Update Center updatetool has support for multiple user images as one 
of its primary features. It manipulates multiple images from a single 
process.
> Please junk the last empty line in os_windows.py.
>   
I added this to make webrev stop complaining about a missing newline at 
the end of the file. I'll delete the line before checking this in.

Thanks.
Tom

_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to