refactor: split state cache storage for subdirs
Currently, the subdir state, which is only present/needed in the root
directory, is part of the regular state cache. It is, however, quite
special and has a very different access pattern, and special
requirements on when changes should be made/persisted.
To facilitate state handling, split out this special root state into its
own file, `.vmtdirstate`, whic will only be present in the maildir root.
To avoid concurrency issues, the file will only be updated by a special
thread that collects results from the worker threads.
Split out this way, the new synchronization with the worker threads
ensures that the directory state is always updated at the right time,
regardless of updates to the regular state in the root directory.
Previously, updates to the directories were sometimes written
prematurely (due to changes in the regular state), which could then lead
to data loss if the current operation errored out or was aborted.
The change is sort of backwards compatible. Vsync will start adding
subdirectories to the new root state file as they get processed (i.e.
there are actual changes to process). However, the absence of a
subdirectory from the file only means the remote mailbox won't get
deleted if the local one does, so there is no hurry to add them. Once
the inbox is being processed, the regular state will be saved without
the `subdirs` entry.