forked from michaeltout/VerusConnect
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/v0.7.1' into dev
# Conflicts: # .gitlab-ci.yml
- Loading branch information
Showing
39 changed files
with
1,225 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Verus-Desktop-GUI
updated
131 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const fs = require('fs-extra'); | ||
|
||
module.exports = (api) => { | ||
/** | ||
* Backs up all necessary app data stored for Verus Desktop | ||
*/ | ||
api.backupAppData = async (backupName) => { | ||
if ( | ||
backupName.includes(".") || | ||
backupName.includes("/") || | ||
backupName.includes("\\") || | ||
backupName.includes("*") || | ||
backupName.includes("~") || | ||
backupName == null | ||
) { | ||
throw new Error(`Backup data name (${backupName}) cannot include any of the following: ./\\*~`) | ||
} | ||
|
||
try { | ||
await fs.access(api.agamaDir, fs.constants.R_OK); | ||
} catch (e) { | ||
if (e.code == "EACCES") { | ||
await fs.chmod(path, "0666"); | ||
} else if (e.code === "ENOENT") { | ||
api.handleFileProblem(`Verus Desktop directory not found`, !handleErrors) | ||
return | ||
} | ||
} | ||
|
||
try { | ||
const backupPath = `${api.backupDir}/${backupName}` | ||
|
||
if (await fs.exists(backupPath)) { | ||
throw new Error(`Backup at ${backupPath} already exists!`) | ||
} | ||
|
||
await fs.copy(api.agamaDir, backupPath); | ||
|
||
api.log( | ||
`appdata backup created at ${backupPath}`, | ||
"backup" | ||
); | ||
api.writeLog(`appdata backup created at ${backupPath}`); | ||
return | ||
} catch (e) { | ||
api.log(e, 'backup'); | ||
api.writeLog(e) | ||
throw e | ||
} | ||
}; | ||
|
||
api.post('/backup_appdata', async (req, res, next) => { | ||
const { token, dirName } = req.body | ||
|
||
if (api.checkToken(token)) { | ||
try { | ||
const retObj = { | ||
msg: 'success', | ||
result: await api.backupAppData(dirName), | ||
}; | ||
|
||
res.end(JSON.stringify(retObj)); | ||
} catch (e) { | ||
const retObj = { | ||
msg: 'error', | ||
result: e.message, | ||
}; | ||
|
||
res.end(JSON.stringify(retObj)); | ||
} | ||
} else { | ||
const retObj = { | ||
msg: 'error', | ||
result: 'unauthorized access', | ||
}; | ||
|
||
res.end(JSON.stringify(retObj)); | ||
} | ||
}); | ||
|
||
return api; | ||
}; |
Oops, something went wrong.