mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
98_configdb.pm: fix pah's strange ideas regarding filenames
git-svn-id: https://svn.fhem.de/fhem/trunk@27168 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4d81a068ea
commit
f6c4c7057f
@ -21,9 +21,25 @@ sub configdb_Initialize {
|
||||
$cmds{configdb} = \%hash;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub CommandConfigdb {
|
||||
my ($cl, $param) = @_;
|
||||
|
||||
sub makeFilename{
|
||||
my $f = shift;
|
||||
my $filename = "";
|
||||
$f =~ s/^["']//; # fix pah strange ideas
|
||||
$f =~ s/["']$//; # dto.
|
||||
if($f =~ m,^[./],) {
|
||||
$filename = $f;
|
||||
} else {
|
||||
$filename = $attr{global}{modpath};
|
||||
$filename .= "/$f";
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
|
||||
my @a = split("[ \t][ \t]*", $param);
|
||||
my ($cmd, $param1, $param2) = @a;
|
||||
$cmd //= "";
|
||||
@ -88,13 +104,7 @@ sub CommandConfigdb {
|
||||
|
||||
when ('filedelete') {
|
||||
return "\n Syntax: configdb filedelete <pathToFile>" if @a != 2;
|
||||
my $filename;
|
||||
if($param1 =~ m,^[./],) {
|
||||
$filename = $param1;
|
||||
} else {
|
||||
$filename = $attr{global}{modpath};
|
||||
$filename .= "/$param1";
|
||||
}
|
||||
my $filename = makeFilename($param1);
|
||||
$ret = "File $filename ";
|
||||
$ret .= defined(_cfgDB_Filedelete($filename)) ? "deleted from" : "not found in";
|
||||
$ret .= " database.";
|
||||
@ -103,13 +113,7 @@ sub CommandConfigdb {
|
||||
when ('fileexport') {
|
||||
return "\n Syntax: configdb fileexport <pathToFile>" if @a != 2;
|
||||
if ($param1 ne 'all') {
|
||||
my $filename;
|
||||
if($param1 =~ m,^[./],) {
|
||||
$filename = $param1;
|
||||
} else {
|
||||
$filename = $attr{global}{modpath};
|
||||
$filename .= "/$param1";
|
||||
}
|
||||
my $filename = makeFilename($param1);
|
||||
$ret = _cfgDB_Fileexport $filename;
|
||||
} else { # start export all
|
||||
my $flist = _cfgDB_Filelist(1);
|
||||
@ -128,13 +132,7 @@ sub CommandConfigdb {
|
||||
|
||||
when ('fileimport') {
|
||||
return "\n Syntax: configdb fileimport <pathToFile>" if @a != 2;
|
||||
my $filename;
|
||||
if($param1 =~ m,^[./],) {
|
||||
$filename = $param1;
|
||||
} else {
|
||||
$filename = $attr{global}{modpath};
|
||||
$filename .= "/$param1";
|
||||
}
|
||||
my $filename = makeFilename($param1);
|
||||
if ( -r $filename ) {
|
||||
my $filesize = -s $filename;
|
||||
$ret = _cfgDB_binFileimport($filename,$filesize);
|
||||
@ -151,13 +149,7 @@ sub CommandConfigdb {
|
||||
|
||||
when ('filemove') {
|
||||
return "\n Syntax: configdb filemove <pathToFile>" if @a != 2;
|
||||
my $filename;
|
||||
if($param1 =~ m,^[./],) {
|
||||
$filename = $param1;
|
||||
} else {
|
||||
$filename = $attr{global}{modpath};
|
||||
$filename .= "/$param1";
|
||||
}
|
||||
my $filename = makeFilename($param1);
|
||||
if ( -r $filename ) {
|
||||
my $filesize = -s $filename;
|
||||
$ret = _cfgDB_binFileimport ($filename,$filesize,1);
|
||||
@ -212,6 +204,15 @@ sub CommandConfigdb {
|
||||
$ret = _cfgDB_Recover($param1);
|
||||
}
|
||||
|
||||
when ('renum') {
|
||||
Log3('configdb', 4, "configdb: renum requested for device: $param1.");
|
||||
return "Unknown device $param1" if !defined $defs{$param1};
|
||||
my $oldnum = $defs{$param1}{NR};
|
||||
$defs{$param1}{NR} = 2;
|
||||
$ret = "configdb: renum requested for device: $param1 \n";
|
||||
$ret .= "use 'save config' and 'shutdown restart' to make changes persistant.";
|
||||
}
|
||||
|
||||
when ('reorg') {
|
||||
$param1 = 3 unless $param1;
|
||||
return "Invalid paramaeter '$param1' for reorg. Must be a number."
|
||||
|
Loading…
Reference in New Issue
Block a user