How to use the maestral.sync.errors.RevFileError function in maestral

To help you get started, we’ve selected a few maestral examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SamSchott / maestral-dropbox / maestral / sync / monitor.py View on Github external
:param bool raise_exception: If ``True``, raises an exception when saving fails.
            Defaults to ``False``.
        :raises: PermissionError, OSError
        """
        new_exc = None

        with self._rev_lock:
            try:
                with open(self.rev_file_path, "w+b") as f:
                    umsgpack.pack(self._rev_dict_cache, f)
            except PermissionError as exc:
                title = "Could not save index"
                msg = ("Insufficient permissions for Dropbox folder. Please "
                       "make sure that you have read and write permissions.")
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except OSError as exc:
                title = "Could not save index"
                msg = "Please check the logs for more information"
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)

            if new_exc:
                if raise_exception:
                    raise new_exc
                else:
                    exc_info = (type(new_exc), new_exc, new_exc.__traceback__)
                    logger.error(title, exc_info=exc_info)
github SamSchott / maestral-dropbox / maestral / sync / monitor.py View on Github external
rev_dict_cache = dict()
        new_exc = None

        with self._rev_lock:
            try:
                with open(self.rev_file_path, "rb") as f:
                    rev_dict_cache = umsgpack.unpack(f)
                assert isinstance(rev_dict_cache, dict)
                assert all(isinstance(key, str) for key in rev_dict_cache.keys())
                assert all(isinstance(val, str) for val in rev_dict_cache.values())
            except (FileNotFoundError, IsADirectoryError):
                logger.warning("Maestral index could not be found.")
            except (AssertionError, umsgpack.InsufficientDataException) as exc:
                title = "Corrupted index"
                msg = "Maestral index has become corrupted. Please rebuild."
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except PermissionError as exc:
                title = "Could not load index"
                msg = ("Insufficient permissions for Dropbox folder. Please "
                       "make sure that you have read and write permissions.")
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except OSError as exc:
                title = "Could not load index"
                msg = "Please resync your Dropbox to rebuild the index."
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)

            if new_exc:
                if raise_exception:
                    raise new_exc
                else:
                    exc_info = (type(new_exc), new_exc, new_exc.__traceback__)
                    logger.error(title, exc_info=exc_info)
github SamSchott / maestral-dropbox / maestral / sync / monitor.py View on Github external
with open(self.rev_file_path, "rb") as f:
                    rev_dict_cache = umsgpack.unpack(f)
                assert isinstance(rev_dict_cache, dict)
                assert all(isinstance(key, str) for key in rev_dict_cache.keys())
                assert all(isinstance(val, str) for val in rev_dict_cache.values())
            except (FileNotFoundError, IsADirectoryError):
                logger.warning("Maestral index could not be found.")
            except (AssertionError, umsgpack.InsufficientDataException) as exc:
                title = "Corrupted index"
                msg = "Maestral index has become corrupted. Please rebuild."
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except PermissionError as exc:
                title = "Could not load index"
                msg = ("Insufficient permissions for Dropbox folder. Please "
                       "make sure that you have read and write permissions.")
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except OSError as exc:
                title = "Could not load index"
                msg = "Please resync your Dropbox to rebuild the index."
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)

            if new_exc:
                if raise_exception:
                    raise new_exc
                else:
                    exc_info = (type(new_exc), new_exc, new_exc.__traceback__)
                    logger.error(title, exc_info=exc_info)

            return rev_dict_cache
github SamSchott / maestral-dropbox / maestral / sync / monitor.py View on Github external
assert all(isinstance(val, str) for val in rev_dict_cache.values())
            except (FileNotFoundError, IsADirectoryError):
                logger.warning("Maestral index could not be found.")
            except (AssertionError, umsgpack.InsufficientDataException) as exc:
                title = "Corrupted index"
                msg = "Maestral index has become corrupted. Please rebuild."
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except PermissionError as exc:
                title = "Could not load index"
                msg = ("Insufficient permissions for Dropbox folder. Please "
                       "make sure that you have read and write permissions.")
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except OSError as exc:
                title = "Could not load index"
                msg = "Please resync your Dropbox to rebuild the index."
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)

            if new_exc:
                if raise_exception:
                    raise new_exc
                else:
                    exc_info = (type(new_exc), new_exc, new_exc.__traceback__)
                    logger.error(title, exc_info=exc_info)

            return rev_dict_cache
github SamSchott / maestral-dropbox / maestral / sync / monitor.py View on Github external
"""
        new_exc = None

        with self._rev_lock:
            try:
                with open(self.rev_file_path, "w+b") as f:
                    umsgpack.pack(self._rev_dict_cache, f)
            except PermissionError as exc:
                title = "Could not save index"
                msg = ("Insufficient permissions for Dropbox folder. Please "
                       "make sure that you have read and write permissions.")
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)
            except OSError as exc:
                title = "Could not save index"
                msg = "Please check the logs for more information"
                new_exc = RevFileError(title, msg).with_traceback(exc.__traceback__)

            if new_exc:
                if raise_exception:
                    raise new_exc
                else:
                    exc_info = (type(new_exc), new_exc, new_exc.__traceback__)
                    logger.error(title, exc_info=exc_info)