Destination directories now get created when needed

recovery-function
Jef Roosens 2021-01-16 09:36:23 +01:00
parent 310ac3784e
commit 2660af23d8
3 changed files with 8 additions and 19 deletions

View File

@ -45,10 +45,13 @@ class Spec:
destination if type(destination) == Path else Path(destination) destination if type(destination) == Path else Path(destination)
) )
# Check existence of destination folder # Create destination if non-existent
if not self.destination.exists() or not self.destination.is_dir(): try:
self.destination.mkdir(parents=True, exist_ok=True)
except FileExistsError:
raise NotADirectoryError( raise NotADirectoryError(
"{} doesn't exist or isn't a directory.".format( "{} already exists, but isn't a directory.".format(
self.destination self.destination
) )
) )

View File

@ -36,6 +36,6 @@ specs:
directories: directories:
test: test:
destination: "/home/jjr/test" destination: "/tmp/to"
limit: 5 limit: 5
source: "/home/jjr" source: "/tmp/from"

View File

@ -1,14 +0,0 @@
defaults:
directories:
notify:
title: 'yeet'
events:
- 'random'
limit: 7
specs:
directories:
test:
source: '/tmp/from'
destination: '/tmp/to'