mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Backup remote restore
This commit is contained in:
parent
6abd4568e1
commit
fb62a9684b
3 changed files with 11 additions and 6 deletions
|
@ -29,7 +29,7 @@ from packaging import version
|
|||
|
||||
from moulinette import Moulinette, m18n
|
||||
from moulinette.utils.log import getActionLogger
|
||||
from moulinette.utils.filesystem import read_file, mkdir, write_to_yaml, read_yaml, rm, chown, chmod, write_to_file
|
||||
from moulinette.utils.filesystem import mkdir, write_to_yaml, read_yaml, rm, chown, chmod, write_to_file
|
||||
from moulinette.utils.process import check_output
|
||||
|
||||
import yunohost.domain
|
||||
|
@ -58,8 +58,6 @@ from yunohost.log import OperationLogger, is_unit_operation
|
|||
from yunohost.repository import BackupRepository, BackupArchive
|
||||
from yunohost.utils.config import ConfigPanel
|
||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||
from yunohost.utils.packages import ynh_packages_version
|
||||
from yunohost.utils.filesystem import free_space_in_directory, disk_usage, binary_to_human
|
||||
from yunohost.utils.system import (
|
||||
free_space_in_directory,
|
||||
get_ynh_package_version,
|
||||
|
|
|
@ -42,7 +42,7 @@ from datetime import timedelta, datetime
|
|||
import yunohost.repositories
|
||||
from yunohost.utils.config import ConfigPanel
|
||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||
from yunohost.utils.filesystem import disk_usage, binary_to_human
|
||||
from yunohost.utils.system import disk_usage, binary_to_human
|
||||
from yunohost.utils.network import get_ssh_public_key, SHF_BASE_URL
|
||||
|
||||
logger = getActionLogger('yunohost.repository')
|
||||
|
@ -184,8 +184,7 @@ class BackupRepository(ConfigPanel):
|
|||
if self.values.get('method') == 'tar' and self.values['is_remote']:
|
||||
raise YunohostError("repository_tar_only_local")
|
||||
|
||||
if 'shf_id' in self.values:
|
||||
self.values['is_shf'] = bool(self.values['shf_id'])
|
||||
self.values['is_shf'] = bool(self.values['shf_id']) if 'shf_id' in self.values else False
|
||||
|
||||
def _parse_pre_answered(self, *args):
|
||||
super()._parse_pre_answered(*args)
|
||||
|
|
|
@ -58,6 +58,14 @@ def space_used_by_directory(dirpath, follow_symlinks=True):
|
|||
return stat.f_frsize * stat.f_blocks # FIXME : this doesnt do what the function name suggest this does ...
|
||||
|
||||
|
||||
def disk_usage(path):
|
||||
# We don't do this in python with os.stat because we don't want
|
||||
# to follow symlinks
|
||||
|
||||
du_output = check_output(["du", "-sb", path], shell=False)
|
||||
return int(du_output.split()[0])
|
||||
|
||||
|
||||
def human_to_binary(size: str) -> int:
|
||||
|
||||
symbols = ("K", "M", "G", "T", "P", "E", "Z", "Y")
|
||||
|
|
Loading…
Add table
Reference in a new issue