-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproviders.js
More file actions
59 lines (55 loc) · 1.72 KB
/
providers.js
File metadata and controls
59 lines (55 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const { rsync, log_dir } = require('./config')
const path = require('path')
const db = require('./db')
const fs = require('fs')
/*
* each provider is like
* (params,id) => {return {args: [], after: (err)=>{...}}}
* you can use the after hook to provide the `diskUsage` info
*/
module.exports = {
'rsync': (repo_params,id,provider_all_params) => {
var params = repo_params;
console.log(params)
if (params.hasOwnProperty('env')) {
args = [`${params.env} `]
} else {
args = []
}
args.push(rsync.command)
if (provider_all_params=="") {
var params = repo_params;
args.push(params.url);
} else {
var params = provider_all_params;
args.push(params.url+"/"+id + "/")
}
if(params.hasOwnProperty('exclude')) {
args.push(`--exclude=${params.exclude}`)
}
if(params.hasOwnProperty('bwlimit')) {
args.push(`--bwlimit=${params.bwlimit}`)
}
if(params.hasOwnProperty('password_file')) {
args.push(`--password-file=${params.password_file}`)
}
if(params.hasOwnProperty('ssh')) {
args.push(`-e ${params.ssh}`)
}
if(params.hasOwnProperty('extras')) {
args.push(`${params.extras}`)
}
//args.push(params.url)
args.push(repo_params.dest || `${path.join(config.repo_dir,id)}`)
return { args, after: async (err) => {
if(!err) {
out = fs.readFileSync(await db.get('logPath',id))
//db.set('diskUsage',(/Total file size: (.*) bytes/).exec(out)[1],id)
}
}}
},
'shell': (repo_params,id,provider_all_params) => {
args = [repo_params.cmd]
return { args }
}
}