2010-07-21 Ramon Novoa <rnovoa@artica.es>
* pandora_agent: Delete unused collections. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3048 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
927110a33b
commit
3e752dbe92
|
@ -1,3 +1,7 @@
|
|||
2010-07-21 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* pandora_agent: Delete unused collections.
|
||||
|
||||
2010-07-20 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* pandora_agent_installer: Fixed some directories and permissions.
|
||||
|
|
|
@ -503,10 +503,23 @@ sub check_remote_config () {
|
|||
}
|
||||
|
||||
################################################################################
|
||||
# Check and download collections.
|
||||
# Delete old collections and download new collections.
|
||||
################################################################################
|
||||
sub check_collections () {
|
||||
|
||||
# Delete old collections
|
||||
opendir (DIR, "$ConfDir/collections") || return;
|
||||
while (defined (my $file_name = readdir(DIR))) {
|
||||
next if ($file_name eq '.' || $file_name eq '..');
|
||||
|
||||
# Do not delete md5 files associated to a collection
|
||||
$file_name =~ s/\.md5$//;
|
||||
|
||||
rmrf ("$ConfDir/collections/$file_name") unless defined ($Collections{$file_name});
|
||||
}
|
||||
closedir (DIR);
|
||||
|
||||
# Download new collections
|
||||
while (my ($collection, $in_path) = each (%Collections)) {
|
||||
my $collection_file = $collection . ".zip";
|
||||
my $collection_md5_file = $collection . ".md5";
|
||||
|
@ -541,7 +554,8 @@ sub check_collections () {
|
|||
|
||||
# Download and unzip
|
||||
next unless (recv_file ($collection_file) == 0);
|
||||
`rm -rf "$ConfDir/collections/$collection" 2>/dev/null && unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>/dev/null`;
|
||||
rmrf ("$ConfDir/collections/$collection");
|
||||
`unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>/dev/null`;
|
||||
unlink ("$Conf{'temporal'}/$collection_file");
|
||||
}
|
||||
}
|
||||
|
@ -1060,6 +1074,26 @@ sub check_module_cron ($) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Recursively delete files and directories.
|
||||
################################################################################
|
||||
sub rmrf {
|
||||
my ($path) = @_;
|
||||
local *DIR;
|
||||
|
||||
if (-d $path) {
|
||||
opendir (DIR, $path) || return;
|
||||
while (defined (my $file_name = readdir(DIR))) {
|
||||
next if ($file_name eq '.' || $file_name eq '..');
|
||||
rmrf ("$path/$file_name");
|
||||
}
|
||||
closedir (DIR);
|
||||
rmdir ($path);
|
||||
} else {
|
||||
unlink ($path);
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Main.
|
||||
################################################################################
|
||||
|
|
Loading…
Reference in New Issue