mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-28 06:51:28 +00:00
beauty(backup): remove stray comments and imports, format
This commit is contained in:
parent
a6dda2d71a
commit
77c267b9c8
|
@ -395,8 +395,6 @@ class Backups:
|
||||||
auto_snaps = Backups._auto_snaps(service)
|
auto_snaps = Backups._auto_snaps(service)
|
||||||
new_snaplist = Backups._prune_snaps_with_quotas(auto_snaps)
|
new_snaplist = Backups._prune_snaps_with_quotas(auto_snaps)
|
||||||
|
|
||||||
# TODO: Can be optimized since there is forgetting of an array in one restic op
|
|
||||||
# but most of the time this will be only one snap to forget.
|
|
||||||
deletable_snaps = [snap for snap in auto_snaps if snap not in new_snaplist]
|
deletable_snaps = [snap for snap in auto_snaps if snap not in new_snaplist]
|
||||||
Backups.forget_snapshots(deletable_snaps)
|
Backups.forget_snapshots(deletable_snaps)
|
||||||
|
|
||||||
|
@ -629,9 +627,10 @@ class Backups:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def forget_all_snapshots():
|
def forget_all_snapshots():
|
||||||
"""deliberately erase all snapshots we made"""
|
"""
|
||||||
# there is no dedicated optimized command for this,
|
Mark all snapshots we have made for deletion and make them inaccessible
|
||||||
# but maybe we can have a multi-erase
|
(this is done by cloud, we only issue a command)
|
||||||
|
"""
|
||||||
Backups.forget_snapshots(Backups.get_all_snapshots())
|
Backups.forget_snapshots(Backups.get_all_snapshots())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -6,7 +6,6 @@ from datetime import datetime, timezone
|
||||||
from selfprivacy_api.graphql.common_types.backup import (
|
from selfprivacy_api.graphql.common_types.backup import (
|
||||||
RestoreStrategy,
|
RestoreStrategy,
|
||||||
BackupReason,
|
BackupReason,
|
||||||
AutobackupQuotas,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from selfprivacy_api.models.backup.snapshot import Snapshot
|
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||||
|
|
|
@ -110,7 +110,7 @@ class BackupMutations:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
job = Jobs.add(
|
job = Jobs.add(
|
||||||
name="trimming autobackup snapshots",
|
name="Trimming autobackup snapshots",
|
||||||
type_id="backups.autobackup_trimming",
|
type_id="backups.autobackup_trimming",
|
||||||
description="Pruning the excessive snapshots after the new autobackup quotas are set",
|
description="Pruning the excessive snapshots after the new autobackup quotas are set",
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,53 +1,49 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path as path
|
import os.path as path
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
from os import remove
|
from os import remove
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from os import urandom
|
from os import urandom
|
||||||
from datetime import datetime, timedelta, timezone, date, time
|
|
||||||
from subprocess import Popen
|
from datetime import datetime, timedelta, timezone
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
import secrets
|
|
||||||
|
|
||||||
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from selfprivacy_api.utils.huey import huey
|
from selfprivacy_api.utils.huey import huey
|
||||||
|
|
||||||
import selfprivacy_api.services as services
|
import selfprivacy_api.services as services
|
||||||
from selfprivacy_api.services import Service, get_all_services
|
from selfprivacy_api.services import Service, get_all_services
|
||||||
from selfprivacy_api.services.service import ServiceStatus
|
|
||||||
|
|
||||||
from selfprivacy_api.services import get_service_by_id
|
from selfprivacy_api.services import get_service_by_id
|
||||||
|
from selfprivacy_api.services.service import ServiceStatus
|
||||||
from selfprivacy_api.services.test_service import DummyService
|
from selfprivacy_api.services.test_service import DummyService
|
||||||
|
|
||||||
from selfprivacy_api.graphql.queries.providers import BackupProvider
|
from selfprivacy_api.graphql.queries.providers import BackupProvider
|
||||||
from selfprivacy_api.graphql.common_types.backup import RestoreStrategy, BackupReason
|
from selfprivacy_api.graphql.common_types.backup import (
|
||||||
|
RestoreStrategy,
|
||||||
|
BackupReason,
|
||||||
|
AutobackupQuotas,
|
||||||
|
)
|
||||||
|
|
||||||
from selfprivacy_api.jobs import Jobs, JobStatus
|
from selfprivacy_api.jobs import Jobs, JobStatus
|
||||||
|
|
||||||
from selfprivacy_api.models.backup.snapshot import Snapshot
|
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||||
|
|
||||||
from selfprivacy_api.graphql.common_types.backup import AutobackupQuotas
|
|
||||||
|
|
||||||
from selfprivacy_api.backup import Backups, BACKUP_PROVIDER_ENVS
|
from selfprivacy_api.backup import Backups, BACKUP_PROVIDER_ENVS
|
||||||
import selfprivacy_api.backup.providers as providers
|
import selfprivacy_api.backup.providers as providers
|
||||||
from selfprivacy_api.backup.providers import AbstractBackupProvider
|
from selfprivacy_api.backup.providers import AbstractBackupProvider
|
||||||
from selfprivacy_api.backup.providers.backblaze import Backblaze
|
from selfprivacy_api.backup.providers.backblaze import Backblaze
|
||||||
from selfprivacy_api.backup.providers.none import NoBackups
|
from selfprivacy_api.backup.providers.none import NoBackups
|
||||||
from selfprivacy_api.backup.util import sync
|
from selfprivacy_api.backup.util import sync
|
||||||
from selfprivacy_api.backup.backuppers.restic_backupper import ResticBackupper
|
|
||||||
from selfprivacy_api.backup.jobs import add_backup_job, add_restore_job
|
|
||||||
|
|
||||||
|
|
||||||
from selfprivacy_api.backup.tasks import (
|
from selfprivacy_api.backup.tasks import (
|
||||||
start_backup,
|
start_backup,
|
||||||
restore_snapshot,
|
restore_snapshot,
|
||||||
reload_snapshot_cache,
|
reload_snapshot_cache,
|
||||||
prune_autobackup_snapshots
|
prune_autobackup_snapshots,
|
||||||
)
|
)
|
||||||
from selfprivacy_api.backup.storage import Storage
|
from selfprivacy_api.backup.storage import Storage
|
||||||
from selfprivacy_api.backup.jobs import get_backup_job
|
|
||||||
|
|
||||||
|
|
||||||
TESTFILE_BODY = "testytest!"
|
TESTFILE_BODY = "testytest!"
|
||||||
|
@ -653,7 +649,7 @@ def test_too_many_auto(backups, dummy_service):
|
||||||
quota.last = 1
|
quota.last = 1
|
||||||
Backups.set_autobackup_quotas(quota)
|
Backups.set_autobackup_quotas(quota)
|
||||||
job = Jobs.add("trimming", "test.autobackup_trimming", "trimming the snaps!")
|
job = Jobs.add("trimming", "test.autobackup_trimming", "trimming the snaps!")
|
||||||
handle=prune_autobackup_snapshots(job)
|
handle = prune_autobackup_snapshots(job)
|
||||||
handle(blocking=True)
|
handle(blocking=True)
|
||||||
snaps = Backups.get_snapshots(dummy_service)
|
snaps = Backups.get_snapshots(dummy_service)
|
||||||
assert len(snaps) == 1
|
assert len(snaps) == 1
|
||||||
|
|
Loading…
Reference in a new issue