Skip to content

Commit c421b2f

Browse files
Fix error in update.sh and added version file creation
1 parent 1334abe commit c421b2f

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

mytonctrl/migrate.py

+23-20
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,29 @@ def migrate(version: 0, local: MyPyClass, ton: MyTonCore):
2525
if version < 1:
2626
local.add_log(f'Running migration {version} -> 1', 'info')
2727
migrate_to_version_1(local, ton)
28+
return 1
2829

2930

3031
def run_migrations(local: Optional[MyPyClass]=None, ton: Optional[MyTonCore]=None):
31-
if local is None:
32-
local = MyPyClass('mytonctrl.py')
33-
if ton is None:
34-
ton = MyTonCore(MyPyClass('mytoncore.py'))
35-
36-
# migrations
37-
local.add_log('Running MyTonCtrl migrations', 'info')
38-
39-
workdir = local.buffer.my_work_dir
40-
local.add_log(f"Workdir: {workdir}", 'info')
41-
42-
version = 0
43-
version_file_path = os.path.join(workdir, 'VERSION')
44-
if os.path.exists(version_file_path):
45-
with open(version_file_path, 'r') as f:
46-
version = int(f.read())
47-
local.add_log(f'Current version: {version}', 'info')
48-
49-
migrate(version, local, ton)
50-
#end define
32+
if local is None:
33+
local = MyPyClass('mytonctrl.py')
34+
if ton is None:
35+
ton = MyTonCore(MyPyClass('mytoncore.py'))
36+
37+
# migrations
38+
local.add_log('Running MyTonCtrl migrations', 'info')
39+
40+
workdir = local.buffer.my_work_dir
41+
local.add_log(f"Workdir: {workdir}", 'info')
42+
43+
version = 0
44+
version_file_path = os.path.join(workdir, 'VERSION')
45+
if os.path.exists(version_file_path):
46+
with open(version_file_path, 'r') as f:
47+
version = int(f.read())
48+
local.add_log(f'Current version: {version}', 'info')
49+
50+
new_version = migrate(version, local, ton)
51+
with open(version_file_path, 'w') as f:
52+
f.write(f'{new_version}')
53+
#end define

mytonctrl/scripts/update.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cd ${srcdir}
3333

3434
# uninstall previous version
3535
rm -rf ${srcdir}/${repo}
36-
pip3 uninstall -y
36+
pip3 uninstall -y mytonctrl
3737

3838
# Update code
3939
echo "https://github.com/${author}/${repo}.git -> ${branch}"

0 commit comments

Comments
 (0)