Exit/abort Save from pre_save_hook?

Currently, all errors in pre_save_hooks are caught and logged, so they cannot cancel the save in progress. This patch will allow you to raise HTTPErrors to cancel saves with a message that will be shown to the user.

Until you can require that, though, you need to implement the quota enforcement by overriding ContentsManager.save instead of a hook:

from tornado.web import HTTPError
from jupyter_server.services.contents.largefilemanager import LargeFileManager

class QuotaFileManager(LargeFileManager):
    def _check_quota(self):
        return True  # whatever you want here

    def save(self, model, path):
        # this bit can move to a hook following https://github.com/jupyter-server/jupyter_server/pull/456
        if not self._check_quota():
            # raising here means cancelling the save
            # the user will see this message in a dialog
            raise HTTPError(400, "Quota exceeded")
        return super().save(model, path)

# use our contents manager subclass
c.ServerApp.contents_manager_class = QuotaFileManager