Remove locks

pull/6/head
Inex Code 2021-12-06 12:00:53 +03:00
parent f68bd88a31
commit 340b50bb0d
1 changed files with 47 additions and 53 deletions

View File

@ -3,7 +3,6 @@ from datetime import datetime
import json
import subprocess
import os
from threading import Lock
from enum import Enum
import portalocker
from selfprivacy_api.utils import ReadUserData
@ -36,7 +35,6 @@ class ResticController:
"""
_instance = None
_lock = Lock()
_initialized = False
def __new__(cls):
@ -110,16 +108,15 @@ class ResticController:
):
return
with self._lock:
with subprocess.Popen(
backup_listing_command,
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
) as backup_listing_process_descriptor:
snapshots_list = backup_listing_process_descriptor.communicate()[
0
].decode("utf-8")
snapshots_list = backup_listing_process_descriptor.communicate()[0].decode(
"utf-8"
)
try:
starting_index = snapshots_list.find("[")
json.loads(snapshots_list[starting_index:])
@ -144,7 +141,6 @@ class ResticController:
f"rclone:backblaze:{self._repository_name}/sfbackup",
"init",
]
with self._lock:
with subprocess.Popen(
initialize_repository_command,
shell=False,
@ -175,7 +171,6 @@ class ResticController:
"backup",
"/var",
]
with self._lock:
with open("/tmp/backup.log", "w", encoding="utf-8") as log_file:
subprocess.Popen(
backup_command,
@ -249,7 +244,6 @@ class ResticController:
self.state = ResticStates.RESTORING
with self._lock:
subprocess.run(backup_restoration_command, shell=False)
self.state = ResticStates.INITIALIZED