Add exception BadDataDirectory.
This commit is contained in:
parent
b89da5dec2
commit
101f6d9c47
2 changed files with 9 additions and 0 deletions
|
@ -152,6 +152,12 @@ class WrongLogin(EtiquetteException):
|
|||
|
||||
|
||||
# GENERAL ERRORS
|
||||
class BadDataDirectory(EtiquetteException):
|
||||
'''
|
||||
Raised by PhotoDB __init__ if the requested data_directory is invalid.
|
||||
'''
|
||||
error_message = 'Bad data directory "{}"'
|
||||
|
||||
OUTOFDATE = '''
|
||||
Database is out of date. {current} should be {new}.
|
||||
Please use utilities\\database_upgrader.py
|
||||
|
|
|
@ -1095,6 +1095,9 @@ class PhotoDB(
|
|||
|
||||
data_directory = helpers.remove_path_badchars(data_directory, allowed=':/\\')
|
||||
self.data_directory = pathclass.Path(data_directory)
|
||||
|
||||
if self.data_directory.exists and not self.data_directory.is_dir:
|
||||
raise exceptions.BadDataDirectory(self.data_directory.absolute_path)
|
||||
os.makedirs(self.data_directory.absolute_path, exist_ok=True)
|
||||
|
||||
self.log = logging.getLogger('etiquette:%s' % self.data_directory.absolute_path)
|
||||
|
|
Loading…
Reference in a new issue