Appendfile: when evaluating quota use attemd to link counts
[exim.git] / src / src / transports / appendfile.c
index 5d23008f85e6b536c1b22f75fe800a2e59140e5f..8f26c71ba3b7e99b949369c207c28c89e3c1c581 100644 (file)
@@ -773,10 +773,9 @@ int count = *countptr;
 struct dirent *ent;
 struct stat statbuf;
 
-dir = opendir(CS dirname);
-if (dir == NULL) return 0;
+if (!(dir = opendir(CS dirname))) return 0;
 
-while ((ent = readdir(dir)) != NULL)
+while ((ent = readdir(dir)))
   {
   uschar * path, * name = US ent->d_name;
 
@@ -815,13 +814,12 @@ while ((ent = readdir(dir)) != NULL)
     DEBUG(D_transport)
       debug_printf("check_dir_size: stat error %d for %s: %s\n", errno, path,
         strerror(errno));
-    continue;
     }
-
-  if ((statbuf.st_mode & S_IFMT) == S_IFREG)
-    sum += statbuf.st_size;
-  else if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
-    sum += check_dir_size(path, &count, regex);
+  else
+    if ((statbuf.st_mode & S_IFMT) == S_IFREG)
+      sum += statbuf.st_size / statbuf.st_nlink;
+    else if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
+      sum += check_dir_size(path, &count, regex);
   }
 
 closedir(dir);