docs: def acquire_lock(cls, mode, user=None):
          """Set a context manager to lock the whole storage.
  
          ``mode`` must either be "r" for shared access or "w" for exclusive
          access.
  
          ``user`` is the name of the logged in user or empty.
  
          """
          if not user:
              return
  
          with EteSyncCache.lock:
              cls.user = user
  
              cls.etesync = cls._get_etesync_for_user(cls.user)
  
              if cls._should_sync():
                  cls._mark_sync()
                  cls.etesync.get_or_create_user_info(force_fetch=True)
                  cls.etesync.sync_journal_list()
                  for journal in cls.etesync.list():
                      cls.etesync.pull_journal(journal.uid)
              yield
              if cls.etesync.journal_list_is_dirty():
                  cls.etesync.sync_journal_list()
              for journal in cls.etesync.list():
                  if cls.etesync.journal_is_dirty(journal.uid):
                      cls.etesync.sync_journal(journal.uid)
  
              cls.etesync = None
              cls.user = None