-
Notifications
You must be signed in to change notification settings - Fork 160
typing: src/vorta/store
#1872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
typing: src/vorta/store
#1872
Changes from 13 commits
6abd0f5
7b80066
5f07abd
b4f2e64
4b299f9
d21316b
4f03af6
767dcc1
1d76358
a5c6729
2f40b7c
77f5c33
f0f33c7
5f5b4e3
0c3829c
eee0b42
65fa36b
bef54e1
73e7d96
8d4ed3b
ba695dd
59803e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ coverage | |
flake8 | ||
macholib | ||
nox | ||
peewee | ||
pkgconfig | ||
pre-commit | ||
pyinstaller | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,18 +28,18 @@ | |||||
|
||||||
|
||||||
@signals.post_save(sender=SettingsModel) | ||||||
def setup_autostart(model_class, instance, created): | ||||||
def setup_autostart(model_class, instance, created) -> None: | ||||||
if instance.key == 'autostart': | ||||||
open_app_at_startup(instance.value) | ||||||
|
||||||
|
||||||
def cleanup_db(): | ||||||
def cleanup_db() -> None: | ||||||
# Clean up database | ||||||
DB.execute_sql("VACUUM") | ||||||
DB.close() | ||||||
|
||||||
|
||||||
def init_db(con=None): | ||||||
def init_db(con=None) -> None: | ||||||
if con is not None: | ||||||
os.umask(0o0077) | ||||||
DB.initialize(con) | ||||||
|
@@ -62,18 +62,18 @@ def init_db(con=None): | |||||
# Delete old log entries after 6 months. | ||||||
# The last `create` command of each profile must not be deleted | ||||||
# since the scheduler uses it to determine the last backup time. | ||||||
last_backups_per_profile = ( | ||||||
last_backups_per_profile = Tuple( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is proper use of type hints. Shouldn't it be the following instead?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
EventLogModel.select(EventLogModel.profile, fn.MAX(EventLogModel.start_time)) | ||||||
.where(EventLogModel.subcommand == 'create') | ||||||
.group_by(EventLogModel.profile) | ||||||
) | ||||||
last_scheduled_backups_per_profile = ( | ||||||
last_scheduled_backups_per_profile = Tuple( | ||||||
EventLogModel.select(EventLogModel.profile, fn.MAX(EventLogModel.start_time)) | ||||||
.where(EventLogModel.subcommand == 'create', EventLogModel.category == 'scheduled') | ||||||
.group_by(EventLogModel.profile) | ||||||
) | ||||||
|
||||||
three_months_ago = datetime.now() - timedelta(days=6 * 30) | ||||||
three_months_ago: datetime = datetime.now() - timedelta(days=6 * 30) | ||||||
SAMAD101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
entry = Tuple(EventLogModel.profile, EventLogModel.start_time) | ||||||
EventLogModel.delete().where( | ||||||
EventLogModel.start_time < three_months_ago, | ||||||
|
@@ -105,11 +105,11 @@ def init_db(con=None): | |||||
s.save() | ||||||
|
||||||
|
||||||
def backup_current_db(schema_version): | ||||||
def backup_current_db(schema_version) -> None: | ||||||
""" | ||||||
Creates a backup copy of settings.db | ||||||
""" | ||||||
|
||||||
timestamp = datetime.now().strftime('%Y-%m-%d-%H%M%S') | ||||||
timestamp: str = datetime.now().strftime('%Y-%m-%d-%H%M%S') | ||||||
SAMAD101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
backup_file_name = f'settings_v{schema_version}_{timestamp}.db' | ||||||
shutil.copy(config.SETTINGS_DIR / 'settings.db', config.SETTINGS_DIR / backup_file_name) |
Uh oh!
There was an error while loading. Please reload this page.