Skip to content

Commit

Permalink
fix: 'archivy init' does not purge old configuration before interacti…
Browse files Browse the repository at this point in the history
…ve init

archivy does not reset the configuration before creating the new user.
This is because archivy calls click.create_admin before resetting the configuration.
It is also recommended to purge the configuration, (and not replace existing conf), to
remove old entries

along with this patch, a new value, VERSION would be added to the configuration
which would be useful in future to migrate old configuration to new configuration tree.
  • Loading branch information
srevinsaju committed Dec 31, 2020
1 parent 2e98de1 commit 1d271fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion archivy/cli.py
Expand Up @@ -7,7 +7,7 @@
from flask.cli import FlaskGroup, load_dotenv, shell_command

from archivy import app
from archivy.config import Config
from archivy.config import Config, VERSION
from archivy.click_web import create_click_web_app
from archivy.data import open_file, format_file, unformat_file
from archivy.helpers import load_config, write_config
Expand Down Expand Up @@ -38,6 +38,9 @@ def init(ctx):
except FileNotFoundError:
pass

# remove the old configuration, and add version to it
write_config({"version": VERSION})

config = Config()
delattr(config, "SECRET_KEY")

Expand Down
5 changes: 5 additions & 0 deletions archivy/config.py
@@ -1,10 +1,15 @@
import os
import appdirs

# version of archivy configuration file
VERSION = 1


class Config(object):
"""Configuration object for the application"""

VERSION = VERSION

def __init__(self):
self.SECRET_KEY = os.urandom(32)
self.PORT = 5000
Expand Down

0 comments on commit 1d271fd

Please sign in to comment.