Skip to content

Commit 1de94e6

Browse files
committed
rm tmp backup dir
1 parent ba1e1c3 commit 1de94e6

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

modules/backups.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import shutil
23
import subprocess
34
import time
45

@@ -30,8 +31,8 @@ def create_backup(self, args):
3031
if len(args) > 1:
3132
color_print("{red}Bad args. Usage:{endc} create_backup [filename]")
3233
return
33-
dir_ = self.create_tmp_ton_dir()
34-
command_args = ["-m", self.ton.local.buffer.my_work_dir, "-t", dir_]
34+
tmp_dir = self.create_tmp_ton_dir()
35+
command_args = ["-m", self.ton.local.buffer.my_work_dir, "-t", tmp_dir]
3536
if len(args) == 1:
3637
command_args += ["-d", args[0]]
3738
backup_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/create_backup.sh')
@@ -41,6 +42,7 @@ def create_backup(self, args):
4142
color_print("create_backup - {green}OK{endc}")
4243
else:
4344
color_print("create_backup - {red}Error{endc}")
45+
shutil.rmtree(tmp_dir)
4446
return process.returncode
4547
# end define
4648

mytoncore/mytoncore.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,8 @@ def clear_dir(self, dir_name):
14671467
ts = os.path.getmtime(os.path.join(dir_name, f))
14681468
if ts < time.time() - week_ago:
14691469
count += 1
1470-
os.remove(os.path.join(dir_name, f))
1470+
if os.path.isfile(os.path.join(dir_name, f)):
1471+
os.remove(os.path.join(dir_name, f))
14711472
self.local.add_log(f"Removed {count} old files from {dir_name} directory for {int(time.time() - start)} seconds", "info")
14721473

14731474
def clear_tmp(self):

mytonctrl/scripts/create_backup.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ cp -r $mtc_dir $tmp_dir
3333
python3 -c "import json;f=open('${tmp_dir}/db/config.json');json.load(f);f.close()" || exit 1 # Check if config.json is copied correctly
3434
python3 -c "import json;f=open('${tmp_dir}/mytoncore/mytoncore.db');json.load(f);f.close()" || exit 2 # Check if mytoncore.db is copied correctly
3535

36-
echo -e "${COLOR}[1/3]${ENDC} Copied files to ${tmp_dir}"
37-
38-
echo -e "${COLOR}[2/3]${ENDC} Started mytoncore service"
36+
echo -e "${COLOR}[1/2]${ENDC} Copied files to ${tmp_dir}"
3937

4038
tar -zcf $dest -C $tmp_dir .
4139

4240
chown $user:$user $dest
4341

44-
echo -e "${COLOR}[3/3]${ENDC} Backup successfully created in ${dest}!"
42+
echo -e "${COLOR}[2/2]${ENDC} Backup successfully created in ${dest}!"
43+
44+
rm -rf $tmp_dir
45+
4546
echo -e "If you wish to use archive package to migrate node to different machine please make sure to stop validator and mytoncore on donor (this) host prior to migration."

0 commit comments

Comments
 (0)