Skip to content

Commit

Permalink
Implement downloading updateall file via the DM
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriiNazarenkoTine committed Apr 8, 2024
1 parent dc57114 commit 0e68136
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/app/getRrReleaseInfo.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ echo ""
USER=$(/usr/syno/synoman/webman/modules/authenticate.cgi)

if [ "${USER}" = "" ]; then
echo -e "Security : user not authenticated\n"
echo '{"error": "Security: user not authenticated"}'
else
# Define the URL for GitHub API
URL="https://api.github.com/repos/RROrg/rr/releases/latest"
Expand All @@ -17,9 +17,11 @@ else

# Extract the tag name from the response
TAG=$(echo "${response}" | jq -r '.tag_name')

RELEASE_LINK=$(echo "${response}" | jq -r '.html_url')
# Read local version
LOCALTAG=$(cat /usr/rr/VERSION 2>/dev/null | grep LOADERVERSION | cut -d'=' -f2)
# Construct the download link
DOWNLOAD_LINK="https://github.com/RROrg/rr/releases/download/${TAG}/updateall-${TAG}.zip"

# Check if LOCALTAG is empty
if [ -z "${LOCALTAG}" ]; then
Expand All @@ -31,16 +33,16 @@ else
# Generate output JSON
if [ "${TAG}" = "${LOCALTAG}" ]; then
# Use jq to generate JSON for up-to-date status
echo "{}" | jq --arg tag "$TAG" --arg message "Actual version is ${TAG}" \
'.status = "up-to-date" | .tag = $tag | .message = $message'
echo "{}" | jq --arg tag "$TAG" --arg url "$RELEASE_LINK" --arg updateAllUrl "$DOWNLOAD_LINK" --arg message "Actual version is ${TAG}" \
'.status = "up-to-date" | .tag = $tag | .message = $message | .url = $url | .updateAllUrl = $updateAllUrl'
else
# Use jq to generate JSON for update available, including release notes
# Fetch and escape release notes from GitHub API response
releaseNotes=$(echo "${response}" | jq '.body')

# Use jq to build the JSON response
echo "{}" | jq --arg tag "$TAG" --argjson notes "$releaseNotes" \
'.status = "update available" | .tag = $tag | .notes = $notes'
echo "{}" | jq --arg tag "$TAG" --argjson notes "$releaseNotes" --arg url "$RELEASE_LINK" --arg updateAllUrl "$DOWNLOAD_LINK" \
'.status = "update available" | .tag = $tag | .notes = $notes | .url = $url | .updateAllUrl = $updateAllUrl'
fi

fi
16 changes: 10 additions & 6 deletions src/app/rr-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ Ext.define("SYNOCOMMUNITY.RRManager.Overview.Main", {
self.rrVersionText = self.rrConfig.rr_version;
if (!self.installed) {
//create rr tmp folder
const rrManagerConfig = self.rrConfig.rr_manager_config;
self.rrManagerConfig = self.rrConfig.rr_manager_config;
SYNO.API.currentManager.requestAPI('SYNO.FileStation.CreateFolder', "create", "2", {
folder_path: `/${rrManagerConfig.SHARE_NAME}`,
name: rrManagerConfig.RR_TMP_DIR,
folder_path: `/${self.rrManagerConfig.SHARE_NAME}`,
name: self.rrManagerConfig.RR_TMP_DIR,
force_parent: false
});
self.installed = true;
Expand All @@ -485,9 +485,13 @@ Ext.define("SYNOCOMMUNITY.RRManager.Overview.Main", {
self.panels.healthPanel.fireEvent("data_ready");
self.loaded = true;
}
function donwloadUpdate(){
//TODO: implement download update
debugger;
function donwloadUpdate() {
SYNO.API.currentManager.requestAPI('SYNO.DownloadStation2.Task', "create", "2", {
type: "url",
destination: `${self.rrManagerConfig.SHARE_NAME}/${self.rrManagerConfig.RR_TMP_DIR}`,
create_list: true,
url: [self.rrCheckVersion.updateAllUrl]
});
}
if (self?.rrCheckVersion?.status == "update available") {
self.appWin.getMsgBox().confirmDelete(
Expand Down

0 comments on commit 0e68136

Please sign in to comment.