diff --git a/README.md b/README.md index 59d70ad..4d0e048 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,9 @@ For development: For production: * Copy `config.ini.example`to `config.ini` and set the proper parameters - * Create an `arec-watcher` user * Install the systemd unit file: `sudo cp arec-watcher.service /etc/systemd/system/` + * Edit the unit file so the watcher runs as the same user that + uploads arec recordings. * Activate the service: `sudo systemctl enable arec-watcher.service` * Run the service: `sudo systemctl start arec-watcher.service` diff --git a/watcher/watcher.py b/watcher/watcher.py index 014345a..3789f01 100644 --- a/watcher/watcher.py +++ b/watcher/watcher.py @@ -1,4 +1,5 @@ import logging +import os from pathlib import Path @@ -53,6 +54,11 @@ class Watcher(PatternMatchingEventHandler): return self.logger.info('Picked up %s', basedir) + + # The arec upload fails to respect the parent's ACL, + # so we have to fix the permissions here. + self._make_group_writable(basedir) + try: result = requests.post(self.notify_url, data={'upload_dir': basedir}) @@ -72,3 +78,8 @@ class Watcher(PatternMatchingEventHandler): def on_moved(self, event): self._process(Path(event.dest_path)) + + def _make_group_writable(self, path: Path): + # Python doesn't have any good tools for recursive permissions, + # so we lean on the OS. + os.system(f'chmod -R g+w {path}')