def check_all_folders(self, force=False):
        """
        This goes through all of the folders and sees if any of the mtimes we
        have on disk disagree with the mtimes we have in the database.

        If they do we then do a resync of that folder.

        If the folder is an active folder it may cause messages to be generated
        and sent to clients that are watching it in some way.

        The folder's \Marked and \Unmarked attributes maybe set in the process
        of this run.

        - `force` : If True this will force a full resync on all
                    mailbox regardless of their mtimes.
        """
        start_time = time.time()
        self.log.debug("check_all_folders begun")

        # Get all of the folders and mtimes we know about from the sqlite db at
        # the beginning. This takes more memory (not _that_ much really in the
        # grand scheme of things) but it gives the answers in one go-round to
        # the db and we get to deal with the data in an easier format.
        #
        mboxes = []
        c = self.db.cursor()
        c.execute("select name, mtime from mailboxes where attributes "
                  "not like '%%ignored%%' order by name")
        for row in c:
            mboxes.append(row)
        c.close()

        # Now go through all of the extant mailboxes and see
        # if their mtimes have changed warranting us to force them to resync.
        #
        # XXX We should probably skip folders that are active and have been
        #     resync'd in the last 30 seconds because those are already checked
        #     by another process.
        #
        for mbox_name,mtime in mboxes:
            # If this mailbox is active and has a client idling on it OR if it
            # has queued commands then we can skip doing a resync here. It has
            # being handled already. It is especially important not to do
            # random resyncs on folders that are in the middle of processing a
            # queued command. It might cause messages to be generated and reset
            # various bits of state that are important to the queued command.
            #
            if mbox_name in self.active_mailboxes and \
                    (any(x.idling for x in self.active_mailboxes[mbox_name].clients.itervalues()) or \
                         len(self.active_mailboxes[mbox_name].command_queue) > 0):
                continue

            path = os.path.join(self.mailbox._path, mbox_name)
            seq_path = os.path.join(path, ".mh_sequences")
            try:
                fmtime = asimap.mbox.Mailbox.get_actual_mtime(self.mailbox,
                                                              mbox_name)
                if (fmtime > mtime) or force:
                    # The mtime differs.. force the mailbox to resync.
                    #
                    self.log.debug("check_all_folders: doing resync on '%s' "
                                   "stored mtime: %d, actual mtime: %d" % \
                                       (mbox_name, mtime, fmtime))
                    m = self.get_mailbox(mbox_name, 30)
                    if (m.mtime >= fmtime) and not force:
                        # Looking at the actual mailbox its mtime is NOT
                        # earlier than the mtime of the actual folder so we can
                        # skip this resync. But commit the mailbox data to the
                        # db so that the actual mtime value is stored.
                        #
                        m.commit_to_db()
                    else:
                        # Yup, we need to resync this folder.
                        m.resync(force = force)
            except (MailboxLock, MailboxInconsistency), e:
                # If hit one of these exceptions they are usually
                # transient.  we will skip it. The command processor in
                # client.py knows how to handle these better.
                #
                self.log.warn("check_all_folders: skipping '%s' due to: "
                              "%s" % (mbox_name, str(e)))
            except (OSError, IOError), e:
                if e.errno == errno.ENOENT:
                    self.log.error("check_all_folders: One of %s or %s does "
                                   "not exist for mtime check" % (path,
                                                                  seq_path))

        self.log.debug("check_all_folders finished, Took %f seconds" % \
                           (time.time() - start_time))
        return

    ##################################################################
    #
dataset/ETHPy150Open scanner/asimap/asimap/user_server.py/IMAPUserServer.check_all_folders/original