mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-17 08:02:36 +00:00
fix(backups): change the dump folder
This commit is contained in:
parent
b522c72aaf
commit
27f09d04de
|
@ -3,7 +3,9 @@
|
|||
import base64
|
||||
import typing
|
||||
from typing import List
|
||||
from os import path, mkdir
|
||||
from os import path, mkdir, remove
|
||||
from os import makedirs
|
||||
from os import listdir
|
||||
from os.path import join
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -26,7 +28,7 @@ from selfprivacy_api.utils import USERDATA_FILE, DKIM_DIR, SECRETS_FILE
|
|||
from selfprivacy_api.utils.block_devices import BlockDevices
|
||||
from shutil import copyfile, copytree, rmtree
|
||||
|
||||
CONFIG_STASH_DIR = "/tmp/selfprivacy_config_dump"
|
||||
CONFIG_STASH_DIR = "/etc/selfprivacy/dump"
|
||||
|
||||
|
||||
class ServiceManager(Service):
|
||||
|
@ -233,8 +235,12 @@ class ServiceManager(Service):
|
|||
@classmethod
|
||||
def pre_backup(cls):
|
||||
tempdir = cls.folders[0]
|
||||
rmtree(tempdir, ignore_errors=True)
|
||||
mkdir(tempdir)
|
||||
if not path.exists(tempdir):
|
||||
makedirs(tempdir)
|
||||
|
||||
paths = listdir(tempdir)
|
||||
for file in paths:
|
||||
remove(file)
|
||||
|
||||
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
|
||||
cls.stash_a_path(p)
|
||||
|
|
|
@ -211,6 +211,17 @@ def test_failed_autoback_prevents_more_autobackup(backups, dummy_service):
|
|||
assert Backups.is_time_to_backup_service(dummy_service, now) is False
|
||||
|
||||
|
||||
def test_slices_with_autobackups_disabled(backups, only_dummy_service_and_api):
|
||||
dummy_service = only_dummy_service_and_api
|
||||
do_autobackup()
|
||||
snaps = Backups.get_all_snapshots()
|
||||
assert len(snaps) == 2
|
||||
|
||||
slice = Backups.last_autobackup_slice()
|
||||
assert len(slice) == 2
|
||||
assert set([snap.id for snap in slice]) == set([snap.id for snap in snaps])
|
||||
|
||||
|
||||
def test_slices_minimal(backups, only_dummy_service_and_api):
|
||||
dummy_service = only_dummy_service_and_api
|
||||
backup_period = 13 # minutes
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from os import path
|
||||
from os import mkdir
|
||||
|
||||
from tests.test_backup import backups
|
||||
from tests.common import generate_backup_query
|
||||
|
||||
|
@ -19,6 +21,7 @@ from tests.test_graphql.test_services import (
|
|||
only_dummy_service,
|
||||
dkim_file,
|
||||
)
|
||||
from selfprivacy_api.services import CONFIG_STASH_DIR
|
||||
|
||||
|
||||
API_RELOAD_SNAPSHOTS = """
|
||||
|
@ -607,6 +610,21 @@ def test_reload_snapshots_bare_bare_bare(authorized_client, dummy_service, backu
|
|||
assert snaps == []
|
||||
|
||||
|
||||
def test_induce_autobackup_if_dir_exists(
|
||||
authorized_client, only_dummy_service_and_api, backups
|
||||
):
|
||||
# mkdir(CONFIG_STASH_DIR)
|
||||
dummy_service = only_dummy_service_and_api
|
||||
|
||||
response = api_manual_autobackup(authorized_client)
|
||||
# raise ValueError(get_data(response))
|
||||
data = get_data(response)["backup"]["manualAutobackup"]
|
||||
assert_ok(data)
|
||||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 2
|
||||
|
||||
|
||||
def test_induce_autobackup(authorized_client, only_dummy_service_and_api, backups):
|
||||
dummy_service = only_dummy_service_and_api
|
||||
|
||||
|
|
Loading…
Reference in a new issue