On Sun, Sep 20, 2009 at 02:53:08PM +0200, Thomas Habets wrote:
> On Sun, 20 Sep 2009, Thomas Habets wrote:
>> be currently crashes when you do "be list" right after a "be init". This 
>> fixes that.

> === modified file 'libbe/bugdir.py'
> --- libbe/bugdir.py   2009-07-21 20:20:21 +0000
> +++ libbe/bugdir.py   2009-09-20 20:34:48 +0000
> @@ -460,7 +460,11 @@
>          uuids = []
>          if os.path.exists(self.get_path()):
>              # list the uuids on disk
> -            for uuid in os.listdir(self.get_path("bugs")):
> +            try:
> +                uuidfiles = os.listdir(self.get_path("bugs"))
> +            except OSError, e:
> +                uuidfiles = []
> +            for uuid in uuidfiles:
>                  if not (uuid.startswith('.')):
>                      uuids.append(uuid)
>                      yield uuid

In by be-rr branch I dealt with this a different way:
        if self.sync_with_disk == True and os.path.exists(self.get_path()):
            # list the uuids on disk
            if os.path.exists(self.get_path("bugs")):
                for uuid in os.listdir(self.get_path("bugs")):
                    if not (uuid.startswith('.')):
                        uuids.append(uuid)
                        yield uuid
It hasn't been merged into the trunk branch yet though...  Looking
around, we handle the similiar issue of a missing "comments" directory
in comments.py with
    path = bug.get_path("comments")
    if not os.path.isdir(path):
        ...
Which I think should also be os.path.exists, since we should never
have a non-directory files named "bugs" or "comments".  If we did have
such non-directory files, it would be good if be crashed so people new
it was a problem, rather than failed silently with an empty
comment/bug list.  So I'm changing isdir -> exists in my be-rr branch.

Attachment: pgpxcz6QJ7W0H.pgp
Description: PGP signature

_______________________________________________
Be-devel mailing list
[email protected]
http://void.printf.net/cgi-bin/mailman/listinfo/be-devel

Reply via email to