Skip to content

Commit 1d665c7

Browse files
committed
fix: logic
1 parent 98e81eb commit 1d665c7

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

goneonize/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import "C"
44

55
//export GetVersion
66
func GetVersion() *C.char {
7-
version := "0.0.0"
7+
version := "0.3.9"
88
return C.CString(version)
99
}

neonize/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from .utils.ffmpeg import FFmpeg
33
from .utils.iofile import TemporaryFile
44
from .events import Event
5-
__version__ = '0.0.0'
5+
__version__ = '0.3.10'
66
__all__ = ('NewClient', 'FFmpeg', 'TemporaryFile', 'Event')

neonize/download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import requests
44
from pathlib import Path
55
from tqdm import tqdm
6-
__GONEONIZE_VERSION__ = '0.0.0'
6+
__GONEONIZE_VERSION__ = '0.3.9'
77
__GIT_RELEASE_URL__ = 'https://github.com/krypton-byte/neonize'
88

99
class UnsupportedPlatform(Exception):

tools/build_goneonize_decision.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
11
from io import BytesIO
2+
import os
3+
from os.path import isfile
24
import sys
35
from .github import Github
46
from zipfile import ZipFile
57
from hashlib import md5
68
from pathlib import Path
9+
import glob
710

811
goneonize = Path(__file__).parent.parent / "goneonize"
12+
def get_diff():
13+
ignore = ["goneonize/defproto", "goneonize/go.mod", "goneonize/go.sum"]
14+
file_paths = glob.glob("goneonize/**/*", recursive=True)
15+
files = []
16+
for file in file_paths:
17+
if os.path.isfile(file) and not file.startswith("goneonize/defproto") and not file.startswith('goneonize/neonize') and '__pycache__' not in file and file not in ignore:
18+
files.append(file)
19+
files.append('goneonize/defproto/.sha')
20+
files.remove("goneonize/version.go")
21+
return files
922

23+
def get_current_md5():
24+
data = get_diff()
25+
result = {}
26+
for file in data:
27+
with open(Path(__file__).parent.parent / file, 'rb') as fd:
28+
result[file] = md5(fd.read()).hexdigest()
29+
return result
30+
31+
def check(gh: ZipFile):
32+
hash_file = get_current_md5()
33+
files = list(hash_file)
34+
folder = gh.filelist[0].filename.split('/')[0]
35+
for file in files:
36+
if hash_file[file] != md5(gh.read(f"{folder}/{file}")).hexdigest():
37+
return True
38+
return False
1039

1140
def build_goneonize_decision() -> bool:
1241
"""
@@ -22,19 +51,7 @@ def build_goneonize_decision() -> bool:
2251
try:
2352
github = Github()
2453
zipfile = ZipFile(BytesIO(github.get_last_neonize_release()))
25-
neonize_proto = ""
26-
defproto_sha = ""
27-
for file in zipfile.filelist:
28-
filename = file.filename
29-
if filename.endswith("Neonize.proto"):
30-
neonize_proto = md5(zipfile.read(file.filename)).hexdigest()
31-
elif file.filename.endswith(".sha"):
32-
defproto_sha = zipfile.read(filename).decode()
33-
with open(goneonize / "Neonize.proto", "rb") as file:
34-
current_neonize_proto = md5(file.read()).hexdigest()
35-
with open(goneonize / "defproto" / ".sha", "r") as file:
36-
current_defproto_sha = file.read()
37-
return not (neonize_proto == current_neonize_proto and defproto_sha == current_defproto_sha)
54+
return check(zipfile)
3855
except Exception:
3956
return True
4057

tools/version_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
if parse.set_version:
4040
version.neonize = parse.set_version
4141
elif parse.last:
42-
post = github.get_last_goneonize_version().split(".")
42+
post = github.get_last_version().split(".")
4343
if len(post) > 3:
4444
post[-1] = f"post{post[-1]}"
4545
version.neonize = ".".join(post)

0 commit comments

Comments
 (0)