mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 09:16:51 +00:00
Remove locks
This commit is contained in:
parent
f68bd88a31
commit
340b50bb0d
|
@ -3,7 +3,6 @@ from datetime import datetime
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
from threading import Lock
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import portalocker
|
import portalocker
|
||||||
from selfprivacy_api.utils import ReadUserData
|
from selfprivacy_api.utils import ReadUserData
|
||||||
|
@ -36,7 +35,6 @@ class ResticController:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_instance = None
|
_instance = None
|
||||||
_lock = Lock()
|
|
||||||
_initialized = False
|
_initialized = False
|
||||||
|
|
||||||
def __new__(cls):
|
def __new__(cls):
|
||||||
|
@ -110,16 +108,15 @@ class ResticController:
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
with self._lock:
|
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
backup_listing_command,
|
backup_listing_command,
|
||||||
shell=False,
|
shell=False,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
) as backup_listing_process_descriptor:
|
) as backup_listing_process_descriptor:
|
||||||
snapshots_list = backup_listing_process_descriptor.communicate()[
|
snapshots_list = backup_listing_process_descriptor.communicate()[0].decode(
|
||||||
0
|
"utf-8"
|
||||||
].decode("utf-8")
|
)
|
||||||
try:
|
try:
|
||||||
starting_index = snapshots_list.find("[")
|
starting_index = snapshots_list.find("[")
|
||||||
json.loads(snapshots_list[starting_index:])
|
json.loads(snapshots_list[starting_index:])
|
||||||
|
@ -144,7 +141,6 @@ class ResticController:
|
||||||
f"rclone:backblaze:{self._repository_name}/sfbackup",
|
f"rclone:backblaze:{self._repository_name}/sfbackup",
|
||||||
"init",
|
"init",
|
||||||
]
|
]
|
||||||
with self._lock:
|
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
initialize_repository_command,
|
initialize_repository_command,
|
||||||
shell=False,
|
shell=False,
|
||||||
|
@ -175,7 +171,6 @@ class ResticController:
|
||||||
"backup",
|
"backup",
|
||||||
"/var",
|
"/var",
|
||||||
]
|
]
|
||||||
with self._lock:
|
|
||||||
with open("/tmp/backup.log", "w", encoding="utf-8") as log_file:
|
with open("/tmp/backup.log", "w", encoding="utf-8") as log_file:
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
backup_command,
|
backup_command,
|
||||||
|
@ -249,7 +244,6 @@ class ResticController:
|
||||||
|
|
||||||
self.state = ResticStates.RESTORING
|
self.state = ResticStates.RESTORING
|
||||||
|
|
||||||
with self._lock:
|
|
||||||
subprocess.run(backup_restoration_command, shell=False)
|
subprocess.run(backup_restoration_command, shell=False)
|
||||||
|
|
||||||
self.state = ResticStates.INITIALIZED
|
self.state = ResticStates.INITIALIZED
|
||||||
|
|
Loading…
Reference in a new issue