]> diplodocus.org Git - minc/commitdiff
(update_folders): Only error out if opening .folders failed for any
authorepg <>
Mon, 12 Sep 2005 15:26:54 +0000 (15:26 +0000)
committerepg <>
Mon, 12 Sep 2005 15:26:54 +0000 (15:26 +0000)
reason other than ENOENT.  For ENOENT, we'll go ahead and create it.

minc

diff --git a/minc b/minc
index f1093e8..7951879 100755 (executable)
--- a/minc
+++ b/minc
@@ -608,16 +608,18 @@ sub update_folders {
     my $folders = shift;
     my ($fh, $fn);
 
-    if (not open($fh, "$mh/.folders")) {
+    if (open($fh, "$mh/.folders")) {
+        while (<$fh>) {
+            chomp;
+            $folders->{$_}++;
+        }
+    } elsif (not $!{ENOENT}) {
+        # For ENOENT, we go ahead and create it, else we error and
+        # don't clobber it.
         warn("open($mh/.folders): $!");
         return;
     }
 
-    while (<$fh>) {
-        chomp;
-        $folders->{$_}++;
-    }
-
     eval { ($fh, $fn) = tempfile("$mh/.folders.XXXXX") };
     if ($@) {
         warn("$@");