29 lines
799 B
Nim
29 lines
799 B
Nim
|
##curl -X 'GET' 'https://codeberg.org/api/v1/repos/pswilde/norgbackup/releases/latest -H 'accept: application/json'
|
||
|
##
|
||
|
import httpclient
|
||
|
import json
|
||
|
|
||
|
import ../model/log_type
|
||
|
import version
|
||
|
|
||
|
proc updateNorg*(cur_vers: string)=
|
||
|
initLogger(strfmt = "[$levelname] ")
|
||
|
let latest_url = "https://codeberg.org/api/v1/repos/pswilde/norgbackup/releases/latest"
|
||
|
var client = newHttpClient()
|
||
|
try:
|
||
|
let res = client.get(latest_url)
|
||
|
if res.code == Http200:
|
||
|
let j = res.body.parseJson()
|
||
|
let new_vers = j["tag_name"].getStr()
|
||
|
if new_vers.newerThan(cur_vers):
|
||
|
info "Update available"
|
||
|
else:
|
||
|
info "No new Update available."
|
||
|
else:
|
||
|
debug res.code
|
||
|
debug res.body
|
||
|
error "Cannot access update URL."
|
||
|
except:
|
||
|
error getCurrentExceptionMsg()
|
||
|
|