1 |
3 |
ahitrov@rambler.ru |
#!/usr/bin/perl |
2 |
|
|
|
3 |
|
|
############################################################################## |
4 |
|
|
# $HeadURL: http://developers.rambler.ru/svn/koi8/install/skel/GNUmakefile $ |
5 |
|
|
# $Id: GNUmakefile 47 2006-06-08 08:45:46Z lonerr $ |
6 |
|
|
############################################################################### |
7 |
|
|
|
8 |
|
|
use strict; |
9 |
|
|
use warnings "all"; |
10 |
|
|
|
11 |
|
|
use FindBin; |
12 |
|
|
BEGIN { require "$FindBin::RealBin/../lib/Modules.pm" } |
13 |
|
|
|
14 |
|
|
use locale; |
15 |
|
|
use PidFile; |
16 |
|
|
use Data::Dumper; |
17 |
|
|
use Contenido::Globals; |
18 |
|
|
use Contenido::Init; |
19 |
|
|
use Contenido::File; |
20 |
|
|
use Contenido::File::Scheme::FILE; |
21 |
|
|
use Contenido::File::Scheme::HTTP; |
22 |
|
|
|
23 |
|
|
# begin |
24 |
|
|
Contenido::Init->init(); |
25 |
|
|
PidFile::start($state->{run_dir}, verbose => 1); |
26 |
|
|
my $keeper = Contenido::Keeper->new($state); |
27 |
|
|
|
28 |
|
|
my %files; |
29 |
|
|
|
30 |
|
|
foreach my $class (map { @{$state->{"available_".$_}} } qw(documents links sections)) { |
31 |
|
|
if (my $sub = $class->can("extra_properties")) { |
32 |
|
|
my @extras = grep { lc($_->{"type"}) eq "image" or lc($_->{"type"}) eq "images" } $sub->(); |
33 |
|
|
my @objects = $keeper->get_documents( class => $class, no_limit => 1 ); |
34 |
|
|
|
35 |
|
|
foreach my $object (@objects) { |
36 |
|
|
foreach my $extra (@extras) { |
37 |
|
|
my $image = $object->get_image($extra->{"attr"}); |
38 |
|
|
if ($image) { |
39 |
|
|
if ($extra->{"type"} eq "images") { |
40 |
|
|
foreach (values %$image) { |
41 |
|
|
next unless ref $_; |
42 |
|
|
if ($_->{"filename"}) { |
43 |
|
|
$files{$_->{"filename"}}++; |
44 |
|
|
} |
45 |
|
|
if ($_->{"mini"}{"filename"}) { |
46 |
|
|
$files{$_->{"mini"}{"filename"}}++; |
47 |
|
|
} |
48 |
|
|
} |
49 |
|
|
} else { |
50 |
|
|
if ($image->{"filename"}) { |
51 |
|
|
$files{$image->{"filename"}}++; |
52 |
|
|
} |
53 |
|
|
if ($image->{"mini"}{"filename"}) { |
54 |
|
|
$files{$image->{"mini"}{"filename"}}++; |
55 |
|
|
} |
56 |
|
|
} |
57 |
|
|
} |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
|
} |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
foreach my $dir (@{$state->{"files_dir"}}) { |
64 |
|
|
no strict "refs"; |
65 |
|
|
my $files = &{"Contenido::File::Scheme::".uc(Contenido::File::scheme($dir))."::listing"}($dir); |
66 |
|
|
|
67 |
|
|
foreach my $file (keys %$files) { |
68 |
|
|
unless (exists $files{$file}) { |
69 |
|
|
&{"Contenido::File::Scheme::".uc(Contenido::File::scheme($dir))."::remove"}($dir."/".$file); |
70 |
|
|
} |
71 |
|
|
} |
72 |
|
|
} |