Skip to content

Commit

Permalink
Use create dir when saving state to config dir (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
theychx authored and skorokithakis committed Apr 22, 2018
1 parent 4b141ae commit 6d86ef7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion catt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def save(settings, path):
if path and path.exists():
click.confirm("File already exists. Overwrite?", abort=True)
click.echo("Saving...")
state = CastState(path or STATE_PATH)
state = CastState(path or STATE_PATH, create_dir=True if not path else False)
state.set_data(cst.cc_name, {"controller": cst.name, "data": cst.media_info})


Expand Down
5 changes: 3 additions & 2 deletions catt/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ def get_data(self, name):


class CastState(CattStore):
def __init__(self, state_path):
def __init__(self, state_path, create_dir=False):
super(CastState, self).__init__(state_path)

if create_dir:
self._create_store_dir()
if not self.store_path.exists():
self._write_store({})

Expand Down

0 comments on commit 6d86ef7

Please sign in to comment.