Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit a44426cd authored by Rob Swindell's avatar Rob Swindell 💬

Merge branch 'mlong/importcfg2' into 'master'

Make it possible to import xtrn and xtrnsec from another system (with different indexes)

See merge request !106
parents 076d6f05 88263e4a
...@@ -117,19 +117,52 @@ if(!cnf) { ...@@ -117,19 +117,52 @@ if(!cnf) {
alert("Failed to read " + cnf_fname); alert("Failed to read " + cnf_fname);
exit(-1); exit(-1);
} }
writeln("Backing up " + cnf_fname);
file_backup(cnf_fname,15);
if (cnf_obj == 'xtrn') {
var secs = {};
for (var i in cnf['xtrnsec']) {
secs[cnf['xtrnsec'][i]['code'].toUpperCase()] = i;
}
}
for(var i in list) { for(var i in list) {
var obj = list[i]; var obj = list[i];
var j; var j;
for(j = 0; j < cnf[cnf_obj].length; j++) { for(j = 0; j < cnf[cnf_obj].length; j++) {
if(cnf[cnf_obj][j].code !== undefined) { if(cnf[cnf_obj][j].code !== undefined) {
if(cnf[cnf_obj][j].code == obj.code) if(cnf[cnf_obj][j].code.toUpperCase() == obj.code.toUpperCase())
break; break;
} else { } else {
if(cnf[cnf_obj][j].name == obj.name) if(cnf[cnf_obj][j].name.toUpperCase() == obj.name.toUpperCase())
break; break;
} }
} }
obj.code = obj.code.toUpperCase();
switch (cnf_obj) {
case 'xtrnsec':
delete obj.number;
delete obj.index;
break;
case 'xtrn':
obj.sec_code = obj.sec_code.toUpperCase();
delete obj.number;
delete obj.index;
delete obj.sec_index;
delete obj.sec_number;
if (typeof secs[obj.sec_code] === "undefined") {
writeln("Could not find section " + obj.sec_code + " for program " + (obj.code || obj.name));
continue;
} else {
obj.sec = secs[obj.sec_code];
}
break;
default:
break;
}
if(j < cnf[cnf_obj].length) { if(j < cnf[cnf_obj].length) {
if(!options.overwrite) { if(!options.overwrite) {
writeln("Already exists: " + (obj.name || obj.code)); writeln("Already exists: " + (obj.name || obj.code));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment