Add hook for storage changes
This commit is contained in:
parent
ef63865e31
commit
0263251ecf
4
config
4
config
@ -112,6 +112,10 @@
|
|||||||
# Folder for storing local collections, created if not present
|
# Folder for storing local collections, created if not present
|
||||||
#filesystem_folder = ~/.config/radicale/collections
|
#filesystem_folder = ~/.config/radicale/collections
|
||||||
|
|
||||||
|
# Command that is run after changes to storage
|
||||||
|
#hook =
|
||||||
|
# Example: git add -A && (git diff --cached --quiet || git commit -m "Changes by "%(user)s)
|
||||||
|
|
||||||
|
|
||||||
[logging]
|
[logging]
|
||||||
|
|
||||||
|
@ -30,10 +30,12 @@ import os
|
|||||||
import pprint
|
import pprint
|
||||||
import base64
|
import base64
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import shlex
|
||||||
import socket
|
import socket
|
||||||
import socketserver
|
import socketserver
|
||||||
import ssl
|
import ssl
|
||||||
import threading
|
import threading
|
||||||
|
import subprocess
|
||||||
import wsgiref.simple_server
|
import wsgiref.simple_server
|
||||||
import re
|
import re
|
||||||
import zlib
|
import zlib
|
||||||
@ -348,6 +350,15 @@ class Application:
|
|||||||
status, headers, answer = function(
|
status, headers, answer = function(
|
||||||
environ, read_allowed_items, write_allowed_items,
|
environ, read_allowed_items, write_allowed_items,
|
||||||
content, user)
|
content, user)
|
||||||
|
hook = self.configuration.get("storage", "hook")
|
||||||
|
if lock_mode == "w" and hook:
|
||||||
|
self.logger.debug("Running hook")
|
||||||
|
folder = os.path.expanduser(
|
||||||
|
self.configuration.get("storage",
|
||||||
|
"filesystem_folder"))
|
||||||
|
subprocess.check_call(
|
||||||
|
hook % {"user": shlex.quote(user or "Anonymous")},
|
||||||
|
shell=True, cwd=folder)
|
||||||
else:
|
else:
|
||||||
status, headers, answer = NOT_ALLOWED
|
status, headers, answer = NOT_ALLOWED
|
||||||
else:
|
else:
|
||||||
|
@ -60,7 +60,8 @@ INITIAL_CONFIG = {
|
|||||||
"storage": {
|
"storage": {
|
||||||
"type": "multifilesystem",
|
"type": "multifilesystem",
|
||||||
"filesystem_folder": os.path.expanduser(
|
"filesystem_folder": os.path.expanduser(
|
||||||
"~/.config/radicale/collections")},
|
"~/.config/radicale/collections"),
|
||||||
|
"hook": ""},
|
||||||
"logging": {
|
"logging": {
|
||||||
"config": "/etc/radicale/logging",
|
"config": "/etc/radicale/logging",
|
||||||
"debug": "False",
|
"debug": "False",
|
||||||
|
Loading…
Reference in New Issue
Block a user