mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 20:57:11 +00:00
fhem.pl: restoreDri restructured (Forum #85801)
git-svn-id: https://svn.fhem.de/fhem/trunk@16426 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4bf7c90037
commit
54caab4aaf
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- fhem.pl: restoreDir restructured (Forum #85801)
|
||||
- added: 88_xs1Bridge: added blacklist function
|
||||
- feature: 93_DbLog: V3.9.0, syntax of attribute excludeDevs enhanced
|
||||
- update: 39_Talk2Fhem: Timephrases added, bugfixes and some changes
|
||||
|
@ -27,15 +27,20 @@ CommandRestore($$)
|
||||
{
|
||||
my ($cl,$param) = @_;
|
||||
my @args = split(/ +/,$param);
|
||||
my $list = (@args > 0 && $args[0] eq "list");
|
||||
shift @args if($list);
|
||||
my $all = (@args > 0 && $args[0] eq "-a");
|
||||
shift @args if($all);
|
||||
my $filename = shift @args;
|
||||
|
||||
my $list;
|
||||
$list = shift(@args) if(@args > 0 && $args[0] eq "list");
|
||||
|
||||
my $all;
|
||||
$all = shift @args if(@args > 0 && $args[0] eq "-a");
|
||||
|
||||
my $filename;
|
||||
$filename = shift @args if(@args > 0 && $args[0] !~ m/^-/);
|
||||
|
||||
my $dest = $attr{global}{modpath};
|
||||
my $src = "$dest/restoreDir";
|
||||
|
||||
$list = 1 if(!$list && !$filename);
|
||||
$list = 1 if(!$list && (!$filename || $filename !~ m/20\d\d-\d\d-\d\d/));
|
||||
return "Usage: restore [-a|list] filename|directory"
|
||||
if(@args);
|
||||
|
||||
@ -55,13 +60,11 @@ CommandRestore($$)
|
||||
|
||||
return "$filename is not available for restore" if(!-e "$src/$filename");
|
||||
|
||||
$filename .= "/" if($filename !~ m,/,); # needed for the regexp below
|
||||
$filename =~ m,^([^/]*)/(.*)$,;
|
||||
$src = "$src/$filename";
|
||||
$dest = "$dest/$2" if($2);
|
||||
$dest = "$dest/$1" if($filename =~ m,20\d\d-\d\d-\d\d/(.*)$,);
|
||||
|
||||
return (-f $src ? restoreFile($src,$dest,$all) : restoreDir($src,$dest,$all)).
|
||||
"\n\nrestore finished";
|
||||
return (-f $src ? restoreFile($src,$dest,$all) :
|
||||
restoreDir( $src,$dest,$all) ). "\n\nrestore finished";
|
||||
}
|
||||
|
||||
sub
|
||||
|
@ -271,7 +271,7 @@ doUpdate($$$$)
|
||||
###########################
|
||||
# read in & digest the local control file
|
||||
my $root = $attr{global}{modpath};
|
||||
my $restoreDir = ($arg eq "check" ? "" : restoreDir_init());
|
||||
my $restoreDir = ($arg eq "check" ? "" : restoreDir_init("update"));
|
||||
|
||||
my @locList;
|
||||
if(($arg eq "check" || $arg eq "all") &&
|
||||
|
10
fhem/fhem.pl
10
fhem/fhem.pl
@ -143,7 +143,7 @@ sub readingsDelete($$);
|
||||
sub redirectStdinStdErr();
|
||||
sub rejectDuplicate($$$);
|
||||
sub resolveAttrRename($$);
|
||||
sub restoreDir_init();
|
||||
sub restoreDir_init(;$);
|
||||
sub restoreDir_rmTree($);
|
||||
sub restoreDir_saveFile($$);
|
||||
sub restoreDir_mkDir($$$);
|
||||
@ -1591,7 +1591,7 @@ CommandSave($$)
|
||||
return;
|
||||
}
|
||||
my $restoreDir;
|
||||
$restoreDir = restoreDir_init() if(!configDBUsed());
|
||||
$restoreDir = restoreDir_init("save") if(!configDBUsed());
|
||||
|
||||
@structChangeHist = ();
|
||||
DoTrigger("global", "SAVE", 1);
|
||||
@ -5404,8 +5404,9 @@ restoreDir_rmTree($)
|
||||
}
|
||||
|
||||
sub
|
||||
restoreDir_init()
|
||||
restoreDir_init($)
|
||||
{
|
||||
my ($subDir) = @_;
|
||||
my $root = $attr{global}{modpath};
|
||||
|
||||
my $nDirs = AttrVal("global","restoreDirs", 3);
|
||||
@ -5416,6 +5417,7 @@ restoreDir_init()
|
||||
return "" if($nDirs == 0);
|
||||
|
||||
my $rdName = "restoreDir";
|
||||
$rdName .= "/$subDir" if($subDir);
|
||||
my @t = localtime(gettimeofday());
|
||||
my $restoreDir = sprintf("$rdName/%04d-%02d-%02d",
|
||||
$t[5]+1900, $t[4]+1, $t[3]);
|
||||
@ -5426,7 +5428,7 @@ restoreDir_init()
|
||||
Log 1, "opendir $root/$rdName: $!";
|
||||
return "";
|
||||
}
|
||||
my @oldDirs = sort grep { $_ !~ m/^\./ && $_ ne $restoreDir } readdir(DH);
|
||||
my @oldDirs = sort grep { $_ =~ m/^20\d\d-\d\d-\d\d/ } readdir(DH);
|
||||
closedir(DH);
|
||||
while(int(@oldDirs) > $nDirs) {
|
||||
my $dir = "$root/$rdName/". shift(@oldDirs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user