MCPcopy Create free account
hub / github.com/chavyleung/scripts / apiRevertGlobalBak

Function apiRevertGlobalBak

box/chavy.boxjs.js:866–891  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

864}
865
866async function apiRevertGlobalBak() {
867 const { id: bakcupId } = $.toObj($request.body)
868 const backup = $.getjson(bakcupId)
869 if (backup) {
870 const {
871 chavy_boxjs_sysCfgs,
872 chavy_boxjs_sysApps,
873 chavy_boxjs_sessions,
874 chavy_boxjs_userCfgs,
875 chavy_boxjs_cur_sessions,
876 chavy_boxjs_app_subCaches,
877 ...datas
878 } = backup
879 $.setdata(JSON.stringify(chavy_boxjs_sessions), $.KEY_sessions)
880 $.setdata(JSON.stringify(chavy_boxjs_userCfgs), $.KEY_usercfgs)
881 $.setdata(JSON.stringify(chavy_boxjs_cur_sessions), $.KEY_cursessions)
882 $.setdata(JSON.stringify(chavy_boxjs_app_subCaches), $.KEY_app_subCaches)
883 const isNull = (val) =>
884 [undefined, null, 'null', 'undefined', ''].includes(val)
885 Object.keys(datas).forEach((datkey) =>
886 $.setdata(isNull(datas[datkey]) ? '' : `${datas[datkey]}`, datkey)
887 )
888 }
889 const boxdata = getBoxData()
890 $.json = boxdata
891}
892
893async function apiSaveGlobalBak() {
894 const backups = $.getjson($.KEY_backups, [])

Callers

nothing calls this directly

Calls 5

isNullFunction · 0.70
getBoxDataFunction · 0.70
toObjMethod · 0.45
getjsonMethod · 0.45
setdataMethod · 0.45

Tested by

no test coverage detected