pan-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pan-users] Patch for the `losing subscribed group when user has multipl


From: Charles Kerr
Subject: [Pan-users] Patch for the `losing subscribed group when user has multipler servers' bug.
Date: Mon, 08 May 2006 10:57:51 -0500
User-agent: Mozilla Thunderbird 1.0.8-1.4.1 (X11/20060420)

Duncan wrote:
Sami Haahtinen posted <address@hidden>, excerpted below, on Sun, 07 May 2006 09:58:48 +0300:


I did some digging when i ran in to this. On the first run newsrc is
created for both servers (i had 2). On the second run i saw my subscribed
groups in other groups, i resubscribed and the newsrc contained only the
subscribed groups (for both servers)

Yeah.  Your post was the one I had read and was thinking about when I
confirmed the problem still there in 0.96 (the first time I saw it since I
had only my ISP's servers listed b4, and hadn't bothered actually
subscribing to anything, just sampling the various groups without
subscribing).  I believe yours was the second time I had seen it
reported, the first not all that detailed.

Thanks to both of you for your digging on this one.  Attached is a fix.

cheers,
Charles
--- pan/data-impl/groups.cc.old 2006-05-08 10:50:16.000000000 -0500
+++ pan/data-impl/groups.cc     2006-05-07 23:32:36.000000000 -0500
@@ -129,7 +129,7 @@
     std::set_union (sub.begin(), sub.end(),
                     tmp_sub.begin(), tmp_sub.end(),
                     std::inserter (tmp, tmp.begin()), o);
-    sub.get_container().swap (tmp_sub);
+    sub.get_container().swap (tmp);
   }
 
   // unsub += tmp_unsub
@@ -159,13 +159,14 @@
     delete in;
   }
 
-  // if it's in both _sub and _unsub, remove it from _unsub.
+  // unsub -= sub
+  AlphabeticalQuarkOrdering o;
   std::vector<Quark> tmp;
   tmp.reserve (_unsubscribed.size());
   std::set_difference (_unsubscribed.begin(), _unsubscribed.end(),
                        _subscribed.begin(), _subscribed.end(),
-                       inserter (tmp, tmp.begin()));
-  _unsubscribed.get_container().assign (tmp.begin(), tmp.end());
+                       inserter (tmp, tmp.begin()), o);
+  _unsubscribed.get_container().swap (tmp);
 }
 
 void
@@ -212,25 +213,37 @@
 void
 DataImpl :: load_group_permissions (const DataIO& data_io)
 {
-  _moderated.clear ();
-  _nopost.clear ();
+  std::vector<Quark> m, n;
 
   LineReader * in (data_io.read_group_permissions ());
-  StringView s, group;
-  while (in && !in->fail() && in->getline(group)) {
-    if (group.len && *group.str=='#')
+  StringView s, line;
+  while (in && !in->fail() && in->getline(line))
+  {
+    if (line.len && *line.str=='#')
       continue;
-    else if (!group.pop_last_token (s, ':'))
-      std::cerr << LINE_ID << " I don't understand \"" << group << '"' << 
std::endl;
-    else if (!s.len)
-      std::cerr << LINE_ID << " Permission for " << group << " needs to be one 
of 'y', 'n', or 'm'.\n";
-    else if (*s.str=='m')
-      _moderated.insert (group);
-    else if (*s.str=='n')
-      _nopost.insert (group);
-    else if (*s.str!='y')
-      std::cerr << LINE_ID << " Permission for " << group << " needs to be one 
of 'y', 'n', or 'm'.\n";
-  }
+
+    else if (!line.pop_last_token (s, ':') || !s.len || (*s.str!='y' && 
*s.str!='n' && *s.str!='m')) {
+      std::cerr << LINE_ID << " Group permissions: Can't parse line `" << line 
<< std::endl;
+      continue;
+    }
+
+    const Quark group (line);
+    const char ch = *s.str;
+
+    if (ch == 'm')
+      m.push_back (group);
+    else if (ch == 'n')
+      n.push_back (group);
+  }
+
+  std::sort (m.begin(), m.end());
+  m.erase (std::unique(m.begin(), m.end()), m.end()); 
+  _moderated.get_container().swap (m);
+
+  std::sort (n.begin(), n.end());
+  n.erase (std::unique(n.begin(), n.end()), n.end()); 
+  _nopost.get_container().swap (n);
+
   delete in;
 }
 
@@ -421,6 +434,7 @@
 
     // make a groups_t of groups we didn't already have,
     // and merge it with _unsubscribed (i.e., groups we haven't seen before 
become unsubscribed)
+    AlphabeticalQuarkOrdering o;
     groups.clear ();
     for (const NewGroup *it=newgroups, *end=newgroups+count; it!=end; ++it)
       if (!_subscribed.count (it->group))
@@ -429,7 +443,7 @@
     tmp.clear ();
     std::set_union (groups.begin(), groups.end(),
                     _unsubscribed.begin(), _unsubscribed.end(),
-                    std::back_inserter (tmp));
+                    std::back_inserter (tmp), o);
     tmp.erase (std::unique(tmp.begin(), tmp.end()), tmp.end()); 
     _unsubscribed.get_container().swap (tmp);
   }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]