🔨 Replace request library by got

This commit is contained in:
Sebastien 2020-08-17 16:30:35 +02:00
parent 576fb256fb
commit a281d30529
5 changed files with 246 additions and 511 deletions

View File

@ -6,3 +6,4 @@
- `4` => Upload snap fail - `4` => Upload snap fail
- `5` => Fail create new snap - `5` => Fail create new snap
- `6` => Fail to clean - `6` => Fail to clean
- `7` => Fail to Download snap

View File

@ -1,6 +1,6 @@
{ {
"name": "nexcloud-backup", "name": "nexcloud-backup",
"version": "0.7.9", "version": "0.7.10",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -99,6 +99,7 @@
"version": "6.10.2", "version": "6.10.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
"integrity": "sha1-086gTWsBeyiUrWkED+yLYj60vVI=", "integrity": "sha1-086gTWsBeyiUrWkED+yLYj60vVI=",
"dev": true,
"requires": { "requires": {
"fast-deep-equal": "^2.0.1", "fast-deep-equal": "^2.0.1",
"fast-json-stable-stringify": "^2.0.0", "fast-json-stable-stringify": "^2.0.0",
@ -149,19 +150,6 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
}, },
"asn1": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
"integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
"requires": {
"safer-buffer": "~2.1.0"
}
},
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
},
"astral-regex": { "astral-regex": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz",
@ -176,21 +164,6 @@
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }
}, },
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"aws-sign2": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
},
"aws4": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz",
"integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A=="
},
"axios": { "axios": {
"version": "0.19.0", "version": "0.19.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
@ -218,14 +191,6 @@
"safe-buffer": "5.1.2" "safe-buffer": "5.1.2"
} }
}, },
"bcrypt-pbkdf": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
"requires": {
"tweetnacl": "^0.14.3"
}
},
"body-parser": { "body-parser": {
"version": "1.18.3", "version": "1.18.3",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz",
@ -282,11 +247,6 @@
"integrity": "sha1-s2MKvYlDQy9Us/BRkjjjPNffL3M=", "integrity": "sha1-s2MKvYlDQy9Us/BRkjjjPNffL3M=",
"dev": true "dev": true
}, },
"caseless": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
},
"chalk": { "chalk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@ -377,14 +337,6 @@
"text-hex": "1.0.x" "text-hex": "1.0.x"
} }
}, },
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -453,14 +405,6 @@
} }
} }
}, },
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
"requires": {
"assert-plus": "^1.0.0"
}
},
"debug": { "debug": {
"version": "2.6.9", "version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@ -503,11 +447,6 @@
"object-keys": "^1.0.12" "object-keys": "^1.0.12"
} }
}, },
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"depd": { "depd": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@ -537,15 +476,6 @@
"esutils": "^2.0.2" "esutils": "^2.0.2"
} }
}, },
"ecc-jsbn": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
"requires": {
"jsbn": "~0.1.0",
"safer-buffer": "^2.1.0"
}
},
"ee-first": { "ee-first": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@ -809,11 +739,6 @@
"vary": "~1.1.2" "vary": "~1.1.2"
} }
}, },
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
},
"external-editor": { "external-editor": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz",
@ -836,20 +761,17 @@
} }
} }
}, },
"extsprintf": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
},
"fast-deep-equal": { "fast-deep-equal": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=",
"dev": true
}, },
"fast-json-stable-stringify": { "fast-json-stable-stringify": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
"dev": true
}, },
"fast-levenshtein": { "fast-levenshtein": {
"version": "2.0.6", "version": "2.0.6",
@ -934,21 +856,6 @@
} }
} }
}, },
"forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
},
"form-data": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
},
"forwarded": { "forwarded": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
@ -984,14 +891,6 @@
"pump": "^3.0.0" "pump": "^3.0.0"
} }
}, },
"getpass": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
"requires": {
"assert-plus": "^1.0.0"
}
},
"glob": { "glob": {
"version": "7.1.6", "version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
@ -1042,20 +941,6 @@
"responselike": "^2.0.0" "responselike": "^2.0.0"
} }
}, },
"har-schema": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
"integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
},
"har-validator": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz",
"integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
"requires": {
"ajv": "^6.5.5",
"har-schema": "^2.0.0"
}
},
"has": { "has": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
@ -1096,16 +981,6 @@
"statuses": ">= 1.4.0 < 2" "statuses": ">= 1.4.0 < 2"
} }
}, },
"http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
"requires": {
"assert-plus": "^1.0.0",
"jsprim": "^1.2.2",
"sshpk": "^1.7.0"
}
},
"http2-wrapper": { "http2-wrapper": {
"version": "1.0.0-beta.5.2", "version": "1.0.0-beta.5.2",
"resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz", "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz",
@ -1254,11 +1129,6 @@
"has-symbols": "^1.0.1" "has-symbols": "^1.0.1"
} }
}, },
"is-typedarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
},
"isarray": { "isarray": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
@ -1270,11 +1140,6 @@
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true "dev": true
}, },
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"js-tokens": { "js-tokens": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@ -1291,25 +1156,16 @@
"esprima": "^4.0.0" "esprima": "^4.0.0"
} }
}, },
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
},
"json-buffer": { "json-buffer": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
"integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
}, },
"json-schema": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
},
"json-schema-traverse": { "json-schema-traverse": {
"version": "0.4.1", "version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha1-afaofZUTq4u4/mO9sJecRI5oRmA=" "integrity": "sha1-afaofZUTq4u4/mO9sJecRI5oRmA=",
"dev": true
}, },
"json-stable-stringify-without-jsonify": { "json-stable-stringify-without-jsonify": {
"version": "1.0.1", "version": "1.0.1",
@ -1317,22 +1173,6 @@
"integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
"dev": true "dev": true
}, },
"json-stringify-safe": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
},
"jsprim": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.3.0",
"json-schema": "0.2.3",
"verror": "1.10.0"
}
},
"keyv": { "keyv": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.1.tgz", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.1.tgz",
@ -1518,11 +1358,6 @@
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
"integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==" "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
}, },
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
},
"object-inspect": { "object-inspect": {
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz",
@ -1649,11 +1484,6 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
}, },
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
"prelude-ls": { "prelude-ls": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
@ -1680,11 +1510,6 @@
"ipaddr.js": "1.9.0" "ipaddr.js": "1.9.0"
} }
}, },
"psl": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.6.0.tgz",
"integrity": "sha512-SYKKmVel98NCOYXpkwUqZqh0ahZeeKfmisiLIcEZdsb+WbLv02g/dI5BUmZnIyOe7RzZtLax81nnb2HbvC2tzA=="
},
"pump": { "pump": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
@ -1697,7 +1522,8 @@
"punycode": { "punycode": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew=" "integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew=",
"dev": true
}, },
"qs": { "qs": {
"version": "6.5.2", "version": "6.5.2",
@ -1746,41 +1572,6 @@
"integrity": "sha1-jRnTHPYySCtYkEn4KB+T28uk0H8=", "integrity": "sha1-jRnTHPYySCtYkEn4KB+T28uk0H8=",
"dev": true "dev": true
}, },
"request": {
"version": "2.88.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
"integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
"requires": {
"aws-sign2": "~0.7.0",
"aws4": "^1.8.0",
"caseless": "~0.12.0",
"combined-stream": "~1.0.6",
"extend": "~3.0.2",
"forever-agent": "~0.6.1",
"form-data": "~2.3.2",
"har-validator": "~5.1.0",
"http-signature": "~1.2.0",
"is-typedarray": "~1.0.0",
"isstream": "~0.1.2",
"json-stringify-safe": "~5.0.1",
"mime-types": "~2.1.19",
"oauth-sign": "~0.9.0",
"performance-now": "^2.1.0",
"qs": "~6.5.2",
"safe-buffer": "^5.1.2",
"tough-cookie": "~2.4.3",
"tunnel-agent": "^0.6.0",
"uuid": "^3.3.2"
}
},
"request-progress": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/request-progress/-/request-progress-3.0.0.tgz",
"integrity": "sha1-TKdUCBx/7GP1BeT6qCWqBs1mnb4=",
"requires": {
"throttleit": "^1.0.0"
}
},
"requires-port": { "requires-port": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@ -1953,22 +1744,6 @@
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true "dev": true
}, },
"sshpk": {
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz",
"integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==",
"requires": {
"asn1": "~0.2.3",
"assert-plus": "^1.0.0",
"bcrypt-pbkdf": "^1.0.0",
"dashdash": "^1.12.0",
"ecc-jsbn": "~0.1.1",
"getpass": "^0.1.1",
"jsbn": "~0.1.0",
"safer-buffer": "^2.0.2",
"tweetnacl": "~0.14.0"
}
},
"stack-trace": { "stack-trace": {
"version": "0.0.10", "version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
@ -2114,11 +1889,6 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true "dev": true
}, },
"throttleit": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz",
"integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw="
},
"through": { "through": {
"version": "2.3.8", "version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
@ -2134,22 +1904,6 @@
"os-tmpdir": "~1.0.2" "os-tmpdir": "~1.0.2"
} }
}, },
"tough-cookie": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"requires": {
"psl": "^1.1.24",
"punycode": "^1.4.1"
},
"dependencies": {
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
}
}
},
"triple-beam": { "triple-beam": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
@ -2161,19 +1915,6 @@
"integrity": "sha1-w8GflZc/sKYpc/sJ2Q2WHuQ+XIo=", "integrity": "sha1-w8GflZc/sKYpc/sJ2Q2WHuQ+XIo=",
"dev": true "dev": true
}, },
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"tweetnacl": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
},
"type-check": { "type-check": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
@ -2207,6 +1948,7 @@
"version": "4.2.2", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
"integrity": "sha1-lMVA4f93KVbiKZUHwBCupsiDjrA=", "integrity": "sha1-lMVA4f93KVbiKZUHwBCupsiDjrA=",
"dev": true,
"requires": { "requires": {
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
@ -2244,11 +1986,6 @@
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
}, },
"uuid": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
"integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
},
"v8-compile-cache": { "v8-compile-cache": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
@ -2260,16 +1997,6 @@
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
}, },
"verror": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
"integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
"requires": {
"assert-plus": "^1.0.0",
"core-util-is": "1.0.2",
"extsprintf": "^1.2.0"
}
},
"webdav": { "webdav": {
"version": "2.10.0", "version": "2.10.0",
"resolved": "https://registry.npmjs.org/webdav/-/webdav-2.10.0.tgz", "resolved": "https://registry.npmjs.org/webdav/-/webdav-2.10.0.tgz",

View File

@ -16,8 +16,6 @@
"http-errors": "~1.6.3", "http-errors": "~1.6.3",
"moment": "^2.24.0", "moment": "^2.24.0",
"morgan": "~1.9.1", "morgan": "~1.9.1",
"request": "^2.88.0",
"request-progress": "^3.0.0",
"webdav": "^2.10.0", "webdav": "^2.10.0",
"winston": "^3.2.1" "winston": "^3.2.1"
}, },

View File

@ -1,14 +1,16 @@
const request = require('request');
const progress = require('request-progress');
const statusTools = require('./status'); const statusTools = require('./status');
const fs = require('fs'); const fs = require('fs');
const settingsTools = require('./settingsTools'); const settingsTools = require('./settingsTools');
const moment = require('moment'); const moment = require('moment');
const logger = require('../config/winston'); const logger = require('../config/winston');
const stream = require('stream');
const {promisify} = require('util');
const pipeline = promisify(stream.pipeline);
const got = require ('got');
// !!! FOR DEV PURPOSE ONLY !!! // !!! FOR DEV PURPOSE ONLY !!!
//put token here for dev (ssh port tunelling 'sudo ssh -L 80:hassio:80 root@`hassoi_ip`' + put 127.0.0.1 hassio into host) //put token here for dev (ssh port tunelling 'sudo ssh -L 80:hassio:80 root@`hassoi_ip`' + put 127.0.0.1 hassio into host)
const fallbackToken = "337c70d10b65879325f87d3082dff5a126692f3047d5a0b93d729c156e48f33052fe888779a7a9ba0ec175cddaae601f26682965ebbfb43e" const fallbackToken = "cf199dd47c09839e8310955246e664c767a05c27f5f03078f3a15b04509c8869321a79eecbe5e8101635a7420c2ba06787823f7d5be4b502"
function getSnapshots() { function getSnapshots() {
@ -19,41 +21,40 @@ function getSnapshots() {
} }
let status = statusTools.getStatus(); let status = statusTools.getStatus();
let option = { let option = {
url: "http://hassio/snapshots",
headers: { 'X-HASSIO-KEY': token }, headers: { 'X-HASSIO-KEY': token },
json: true responseType: 'json'
}; };
request(option, (error, response, body) => {
if (!error && response.statusCode === 200) { got("http://hassio/snapshots", option)
if (status.error_code === 1) { .then((result) => {
status.status = "idle"; if (status.error_code === 1) {
status.message = null; status.status = "idle";
status.error_code = null; status.message = null;
statusTools.setStatus(status); status.error_code = null;
}
let snaps = body.data.snapshots;
// console.log(snaps);
resolve(snaps);
}
else {
status.status = "error";
status.message = "Fail to fetch Hassio snapshot (" + error + ")";
status.error_code = 1;
statusTools.setStatus(status); statusTools.setStatus(status);
logger.error(status.message);
reject(error);
} }
let snaps = result.body.data.snapshots;
resolve(snaps);
}) })
.catch((error) => {
status.status = "error";
status.message = "Fail to fetch Hassio snapshots (" + error.message + ")";
status.error_code = 1;
statusTools.setStatus(status);
logger.error(status.message);
reject(error.message);
});
}); });
} }
function downloadSnapshot(id) { function downloadSnapshot(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logger.info('Downloading snapshot ' + id + '...'); logger.info(`Downloading snapshot ${id}...`);
if (!fs.existsSync('./temp/')) if (!fs.existsSync('./temp/'))
fs.mkdirSync('./temp/'); fs.mkdirSync('./temp/');
let stream = fs.createWriteStream('./temp/' + id + '.tar'); let tmp_file = `./temp/${id}.tar`
let stream = fs.createWriteStream(tmp_file);
let token = process.env.HASSIO_TOKEN; let token = process.env.HASSIO_TOKEN;
if (token == null) { if (token == null) {
token = fallbackToken token = fallbackToken
@ -64,158 +65,166 @@ function downloadSnapshot(id) {
status.progress = 0; status.progress = 0;
statusTools.setStatus(status); statusTools.setStatus(status);
let option = { let option = {
url: 'http://hassio/snapshots/' + id + '/download',
headers: { 'X-HASSIO-KEY': token }, headers: { 'X-HASSIO-KEY': token },
}; };
progress(request(option))
.on('progress', (state) => { pipeline(
// TODO Don't write progress to disk, preseve disk IO time got.stream.get(`http://hassio/snapshots/${id}/download`, option)
status.progress = state.percent; .on('downloadProgress', e => {
statusTools.setStatus(status); let percent = Math.round(e.percent * 100) / 100;
if (status.progress != percent) {
status.progress = percent;
statusTools.setStatus(status);
}
}) })
.on('error', (error) => { ,
status.status = "error"; stream
status.message = "Fail to download Hassio snapshot (" + error + ")"; )
status.error_code = 1; .then((res)=>{
statusTools.setStatus(status);
logger.error(status.message);
reject(error);
})
.on('end', () => {
logger.info('Download success !') logger.info('Download success !')
status.progress = 1; status.progress = 1;
statusTools.setStatus(status); statusTools.setStatus(status);
logger.debug("Snapshot dl size : " + (fs.statSync('./temp/' + id + '.tar').size / 1024 / 1024)) logger.debug("Snapshot dl size : " + (fs.statSync(tmp_file).size / 1024 / 1024));
resolve();
}).catch((err)=>{
fs.unlinkSync(tmp_file);
status.status = "error";
status.message = "Fail to download Hassio snapshot (" + err.message + ")";
status.error_code = 7;
statusTools.setStatus(status);
logger.error(status.message);
reject(err.message);
})
}).catch((err) => {
status.status = "error";
status.message = "Fail to download Hassio snapshot. Not found ?";
status.error_code = 7;
statusTools.setStatus(status);
logger.error(status.message);
reject();
});
});
}
function dellSnap(id) {
return new Promise((resolve, reject) => {
checkSnap(id).then(() => {
let token = process.env.HASSIO_TOKEN;
if (token == null) {
token = fallbackToken
}
let option = {
headers: { 'X-HASSIO-KEY': token },
responseType: 'json'
};
got.post(`http://hassio/snapshots/${id}/remove`, option)
.then((result) => {
resolve(); resolve();
}) })
.pipe(stream); .catch((error) => {
}).catch(() => { reject();
status.status = "error"; });
status.message = "Fail to download Hassio snapshot. Not found ?"; }).catch(() => {
status.error_code = 1; reject();
statusTools.setStatus(status); })
logger.error(status.message); })
reject();
});
}); }
}
function dellSnap(id) { function checkSnap(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
checkSnap(id).then(() => {
let token = process.env.HASSIO_TOKEN; let token = process.env.HASSIO_TOKEN;
if (token == null) { if (token == null) {
token = fallbackToken token = fallbackToken
} }
let option = { let option = {
url: 'http://hassio/snapshots/' + id + '/remove',
headers: { 'X-HASSIO-KEY': token }, headers: { 'X-HASSIO-KEY': token },
json: true responseType: 'json'
} };
request.post(option, (error, response, body) => {
if (error || (response.statusCode !== 200 && response.statusCode !== 204))
reject();
else
resolve();
})
}).catch(() => {
reject();
})
})
} got(`http://hassio/snapshots/${id}/info`, option)
.then((result) => {
function checkSnap(id) { logger.debug(`Snapshot size: ${result.body.data.size}`)
return new Promise((resolve, reject) => {
let token = process.env.HASSIO_TOKEN;
if (token == null) {
token = fallbackToken
}
let option = {
url: 'http://hassio/snapshots/' + id + '/info',
headers: { 'X-HASSIO-KEY': token },
json: true
}
request(option, (error, response, body) => {
if (error || response.statusCode != 200)
reject();
else{
logger.debug("Snapshot size: " + body.data.size)
resolve(); resolve();
})
.catch((error) => {
reject();
});
});
}
function createNewBackup(name) {
return new Promise((resolve, reject) => {
let status = statusTools.getStatus();
status.status = "creating";
status.progress = -1;
statusTools.setStatus(status);
logger.info("Creating new snapshot...")
let token = process.env.HASSIO_TOKEN;
if (token == null) {
token = fallbackToken
} }
let option = {
headers: { 'X-HASSIO-KEY': token },
responseType: 'json',
timeout: 2400000,
json: { name: name }
}) };
});
} got.post(`http://hassio/snapshots/new/full`, option)
.then((result) => {
logger.info(`Snapshot created with id ${result.body.data.slug}`);
function createNewBackup(name) { resolve(result.body.data.slug);
return new Promise((resolve, reject) => { })
let status = statusTools.getStatus(); .catch((error) => {
status.status = "creating";
status.progress = -1;
statusTools.setStatus(status);
logger.info("Creating new snapshot...")
let token = process.env.HASSIO_TOKEN;
if (token == null) {
token = fallbackToken
}
let option = {
url: 'http://hassio/snapshots/new/full',
headers: { 'X-HASSIO-KEY': token },
json: true,
body: { name: name },
timeout: 2400000
}
request.post(option, (error, response, body) => {
if (response.statusCode !== 200) {
status.status = "error"; status.status = "error";
status.message = "Can't create new snapshot (" + error + ")"; status.message = "Can't create new snapshot (" + error.message + ")";
status.error_code = 5; status.error_code = 5;
statusTools.setStatus(status); statusTools.setStatus(status);
logger.error(status.message); logger.error(status.message);
reject(status.message); reject(status.message);
}
else {
body.data.slug;
logger.info('Snapshot created with id ' + body.data.slug);
resolve(body.data.slug);
}
});
});
}
function clean() {
let limit = settingsTools.getSettings().auto_clean_backup_keep;
if (limit == null)
limit = 5;
return new Promise((resolve, reject) => {
getSnapshots().then(async (snaps) => {
if (snaps.length < limit) {
resolve();
return;
}
snaps.sort((a, b) => {
if (moment(a.date).isBefore(moment(b.date)))
return 1;
else
return -1;
}); });
let toDel = snaps.slice(limit);
for (let i in toDel) {
await dellSnap(toDel[i].slug)
}
logger.info('Local clean done.')
resolve();
}).catch(() => {
reject();
});
})
}
exports.getSnapshots = getSnapshots;
exports.downloadSnapshot = downloadSnapshot;
exports.createNewBackup = createNewBackup; });
exports.clean = clean; }
function clean() {
let limit = settingsTools.getSettings().auto_clean_backup_keep;
if (limit == null)
limit = 5;
return new Promise((resolve, reject) => {
getSnapshots().then(async (snaps) => {
if (snaps.length < limit) {
resolve();
return;
}
snaps.sort((a, b) => {
if (moment(a.date).isBefore(moment(b.date)))
return 1;
else
return -1;
});
let toDel = snaps.slice(limit);
for (let i in toDel) {
await dellSnap(toDel[i].slug)
}
logger.info('Local clean done.')
resolve();
}).catch(() => {
reject();
});
})
}
exports.getSnapshots = getSnapshots;
exports.downloadSnapshot = downloadSnapshot;
exports.createNewBackup = createNewBackup;
exports.clean = clean;

View File

@ -148,71 +148,71 @@ class WebdavTools {
_startUpload(id, path) { _startUpload(id, path) {
return new Promise( async (resolve, reject) => { return new Promise( async (resolve, reject) => {
let status = statusTools.getStatus(); let status = statusTools.getStatus();
status.status = "upload"; status.status = "upload";
status.progress = 0; status.progress = 0;
status.message = null; status.message = null;
status.error_code = null; status.error_code = null;
statusTools.setStatus(status); statusTools.setStatus(status);
logger.info('Uploading snap...'); logger.info('Uploading snap...');
let tmpFile = `./temp/${id}.tar` let tmpFile = `./temp/${id}.tar`
let fileSize = fs.statSync(tmpFile).size; let fileSize = fs.statSync(tmpFile).size;
let stream = fs.createReadStream(tmpFile); let stream = fs.createReadStream(tmpFile);
let options = { let options = {
body: stream, body: stream,
username: this.username, username: this.username,
password: this.password password: this.password
} }
got.stream.put(this.baseUrl + encodeURI(path), options).on('uploadProgress', e => { got.stream.put(this.baseUrl + encodeURI(path), options).on('uploadProgress', e => {
let percent = e.percent; let percent = e.percent;
if (status.progress != percent) { if (status.progress != percent) {
status.progress = percent; status.progress = percent;
statusTools.setStatus(status); statusTools.setStatus(status);
} }
if (percent >= 1) { if (percent >= 1) {
logger.info('Upload done...'); logger.info('Upload done...');
} }
}).on('response', res => { }).on('response', res => {
if (res.statusCode != 201 && res.statusCode != 204) { if (res.statusCode != 201 && res.statusCode != 204) {
status.status = "error"; status.status = "error";
status.error_code = 4; status.error_code = 4;
status.message = `Fail to upload snapshot to nextcloud (Status code: ${res.statusCode})!`; status.message = `Fail to upload snapshot to nextcloud (Status code: ${res.statusCode})!`;
statusTools.setStatus(status); statusTools.setStatus(status);
logger.error(status.message); logger.error(status.message);
fs.unlinkSync(tmpFile); fs.unlinkSync(tmpFile);
reject(status.message); reject(status.message);
} else { } else {
logger.info(`...Upload finish ! (status: ${res.statusCode})`); logger.info(`...Upload finish ! (status: ${res.statusCode})`);
status.status = "idle"; status.status = "idle";
status.progress = -1; status.progress = -1;
status.message = null; status.message = null;
status.error_code = null; status.error_code = null;
status.last_backup = moment().format('MMM D, YYYY HH:mm'); status.last_backup = moment().format('MMM D, YYYY HH:mm');
statusTools.setStatus(status); statusTools.setStatus(status);
cleanTempFolder(); cleanTempFolder();
let autoCleanCloud = settingsTools.getSettings().auto_clean_backup; let autoCleanCloud = settingsTools.getSettings().auto_clean_backup;
if (autoCleanCloud != null && autoCleanCloud == "true") { if (autoCleanCloud != null && autoCleanCloud == "true") {
this.clean().catch(); this.clean().catch();
} }
let autoCleanlocal = settingsTools.getSettings().auto_clean_local; let autoCleanlocal = settingsTools.getSettings().auto_clean_local;
if (autoCleanlocal != null && autoCleanlocal == "true") { if (autoCleanlocal != null && autoCleanlocal == "true") {
hassioApiTools.clean(); hassioApiTools.clean();
} }
resolve(); resolve();
} }
}).on('error', err => { }).on('error', err => {
fs.unlinkSync(tmpFile); fs.unlinkSync(tmpFile);
status.status = "error"; status.status = "error";
status.error_code = 4; status.error_code = 4;
status.message = `Fail to upload snapshot to nextcloud (${err}) !`; status.message = `Fail to upload snapshot to nextcloud (${err}) !`;
statusTools.setStatus(status); statusTools.setStatus(status);
logger.error(status.message); logger.error(status.message);
reject(status.message); reject(status.message);
}); });
}); });
} }