Skip to content

Commit 4083894

Browse files
committed
添加上传构件到Artifacts的步骤,优化更新状态检查逻辑,重构配置读取功能
1 parent fe485a1 commit 4083894

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
-w /spksrc/spk/rr-manager \
4747
ghcr.io/synocommunity/spksrc \
4848
make arch-${{ matrix.target }}
49+
- name: Upload to Artifacts
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: packages-${{ matrix.target }}
53+
path: |
54+
packages/*.spk
4955
- name: Release
5056
uses: softprops/action-gh-release@v1
5157
if: startsWith(github.ref, 'refs/tags/')
@@ -57,4 +63,4 @@ jobs:
5763
with:
5864
path: |
5965
/home/runner/work/spksrc/distrib
60-
key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}
66+
key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}

src/scripts/checkUpdateStatus.cgi

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,25 @@ if __name__ == "__main__":
4343
rr_manager_config = read_rrmanager_config(
4444
"/var/packages/rr-manager/target/app/config.txt"
4545
)
46-
filename = rr_manager_config.get("RR_UPDATE_PROGRESS_FILE")
46+
RR_TMP_DIR = rr_manager_config.get("RR_TMP_DIR")
47+
RR_UPDATE_PROGRESS_FILE = rr_manager_config.get("RR_UPDATE_PROGRESS_FILE")
4748

48-
if filename:
49+
if RR_TMP_DIR and RR_UPDATE_PROGRESS_FILE:
4950
# Construct file path
50-
file_path = os.path.join("/tmp", filename)
51+
file_path = os.path.join("/", RR_TMP_DIR, RR_UPDATE_PROGRESS_FILE)
5152

5253
if os.path.abspath(file_path).startswith("/tmp/"):
5354
try:
54-
with open(file_path, "r") as file:
55-
content = file.read()
56-
# Attempt to parse the content as JSON
57-
parsed_content = json.loads(content)
58-
# Success, set the result
59-
response["result"] = parsed_content
55+
if os.path.exists(file_path):
56+
with open(file_path, "r") as file:
57+
content = file.read()
58+
# Attempt to parse the content as JSON
59+
parsed_content = json.loads(content)
60+
# Success, set the result
61+
response["result"] = parsed_content
62+
response["success"] = True
63+
else:
64+
response["result"] = '{"progress": "--", "progressmsg": "--"}'
6065
response["success"] = True
6166
except json.JSONDecodeError:
6267
response["status"] = "File content is not valid JSON."

src/scripts/runRrUpdate.cgi

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ def call_mount_loader_script(action):
2525
)
2626

2727

28+
def read_config(file_path):
29+
try:
30+
config = {}
31+
with open(file_path, "r") as file:
32+
for line in file:
33+
line = line.strip()
34+
if line and not line.startswith("#"):
35+
key, value = line.split("=")
36+
config[key.strip()] = value.strip()
37+
return config
38+
except IOError as e:
39+
return f"Error reading user-config.yml: {e}"
40+
except e:
41+
return "{}"
42+
43+
2844
def rmove_file(path, default=None):
2945
try:
3046
if os.path.exists("/usr/sbin/rrmdo"):
@@ -81,8 +97,11 @@ if __name__ == "__main__":
8197
if not file_update:
8298
raise Exception("file is empty")
8399

100+
rr_manager_config = read_config("/var/packages/rr-manager/target/app/config.txt")
101+
RR_TMP_DIR = rr_manager_config.get("RR_TMP_DIR")
102+
RR_UPDATE_PROGRESS_FILE = rr_manager_config.get("RR_UPDATE_PROGRESS_FILE")
84103
# 删除文件
85-
file_progress = "/tmp/rr_update_progress"
104+
file_progress = os.path.join("/", RR_TMP_DIR, RR_UPDATE_PROGRESS_FILE)
86105
rmove_file(file_progress)
87106
# call_mount_loader_script("mountLoaderDisk")
88107
updateRR(file_update, file_progress)

0 commit comments

Comments
 (0)