Hi,
        While running livecd-creator, if you hit ctrl-c while e.g. a repo's
metadata is being downloaded, then livecd-creator fails to clean up
after itself because it can't unmount the yum cache from the chroot.

        It turns out that urlgrabber is failing to close the fd it's writing to
at the time.

        The fix is simple - wrap the read/write loop in try/finally so as to
close the fd if an exception occurs.

Cheers,
Mark.
Index: urlgrabber/grabber.py
===================================================================
RCS file: /cvsroot/urlgrabber/cvs-root/urlgrabber/urlgrabber/grabber.py,v
retrieving revision 1.52
diff -u -p -r1.52 grabber.py
--- urlgrabber/grabber.py	12 Dec 2006 19:08:46 -0000	1.52
+++ urlgrabber/grabber.py	29 Nov 2007 10:42:14 -0000
@@ -1277,20 +1277,22 @@ class URLGrabberFileObject:
         bs = 1024*8
         size = 0
 
-        if amount is not None: bs = min(bs, amount - size)
-        block = self.read(bs)
-        size = size + len(block)
-        while block:
-            try:
-                new_fo.write(block)
-            except IOError, e:
-                raise URLGrabError(16, _(\
-                    'error writing to local file, IOError: %s') % (e, ))
+        try:
             if amount is not None: bs = min(bs, amount - size)
             block = self.read(bs)
             size = size + len(block)
+            while block:
+                try:
+                    new_fo.write(block)
+                except IOError, e:
+                    raise URLGrabError(16, _(\
+                            'error writing to local file, IOError: %s') % (e, ))
+                if amount is not None: bs = min(bs, amount - size)
+                block = self.read(bs)
+                size = size + len(block)
+        finally:
+            new_fo.close()
 
-        new_fo.close()
         try:
             modified_tuple  = self.hdr.getdate_tz('last-modified')
             modified_stamp  = rfc822.mktime_tz(modified_tuple)
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to