line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Followme::UploadData; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
641
|
use 5.008005; |
|
2
|
|
|
|
|
34
|
|
4
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
45
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
55
|
|
|
2
|
|
|
|
|
119
|
|
6
|
2
|
|
|
2
|
|
18
|
use integer; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
19
|
|
7
|
2
|
|
|
2
|
|
59
|
use lib '../..'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
294
|
use base qw(App::Followme::FolderData); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
616
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
14
|
use Digest::MD5 qw(md5_hex); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
118
|
|
12
|
2
|
|
|
2
|
|
15
|
use App::Followme::FIO; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
222
|
|
13
|
2
|
|
|
2
|
|
498
|
use App::Followme::Web; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
581
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = "2.02"; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
# Read the default parameter values |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub parameters { |
21
|
12
|
|
|
12
|
1
|
19
|
my ($self) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return ( |
24
|
12
|
|
|
|
|
27
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
28
|
|
|
|
|
|
|
# Calculate the check sum for a file |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub calculate_checksum { |
31
|
12
|
|
|
12
|
0
|
24
|
my ($self, $filename) = @_; |
32
|
|
|
|
|
|
|
|
33
|
12
|
|
|
|
|
33
|
my $page = fio_read_page($filename, ':raw'); |
34
|
12
|
50
|
|
|
|
39
|
return '' unless $page; |
35
|
|
|
|
|
|
|
|
36
|
12
|
|
|
|
|
84
|
my $md5 = Digest::MD5->new; |
37
|
12
|
|
|
|
|
58
|
$md5->add($page); |
38
|
|
|
|
|
|
|
|
39
|
12
|
|
|
|
|
91
|
return $md5->hexdigest; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
43
|
|
|
|
|
|
|
# Return true if this is an included file |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub match_file { |
46
|
9
|
|
|
9
|
0
|
19
|
my ($self, $filename) = @_; |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
66
|
|
|
34
|
$self->{exclude_file_patterns} ||= fio_glob_patterns($self->{exclude}); |
49
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
24
|
my ($dir, $file) = fio_split_filename($filename); |
51
|
|
|
|
|
|
|
|
52
|
9
|
50
|
|
|
|
51
|
return if $self->match_patterns($file, $self->{exclude_file_patterns}); |
53
|
9
|
|
|
|
|
41
|
return 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding utf-8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
App::Followme::UploadData |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use App::Followme::UploadData; |
69
|
|
|
|
|
|
|
my $meta = App::Followme::UploadData->new(exclude => '*.cfg'); |
70
|
|
|
|
|
|
|
my $index_file = $self->to_file($self->{base_directory}); |
71
|
|
|
|
|
|
|
my $files = App::Followme::Template->build('files', $index_file); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This module generates the list of files and folders to be uploaded to the |
76
|
|
|
|
|
|
|
remote site and the checksums for each file. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 METHODS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
All data classes are first instantiated by calling new and data items are |
81
|
|
|
|
|
|
|
retrieved by calling the build method with the item name as the first argument |
82
|
|
|
|
|
|
|
and the file or folder as the second argument. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 VARIABLES |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The file metadata class can evaluate the following variables. When passing |
87
|
|
|
|
|
|
|
a name to the build method, the sigil should not be used. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item @files |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The list of files to be uploaded from a folder. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item @folders |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The list of folders contining files to be uploaded |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item $checksum |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The MD5 hash of the file contents, used for determining if file has changed |
102
|
|
|
|
|
|
|
and needs to be uploaded. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 CONFIGURATION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This class has the following configuration variables: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=over 4 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item excluded |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
A filename pattern or comma separated list of filename patterns that match files |
115
|
|
|
|
|
|
|
that should not be uploaded. The default value is '*.cfg' which matches |
116
|
|
|
|
|
|
|
configuration files. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item exclude_dirs |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
A filename pattern or comma separated list of filename patterns that match |
121
|
|
|
|
|
|
|
folders that should not be uploaded/ The default value is '.*,_*' which |
122
|
|
|
|
|
|
|
matches folders starting with a dot (hiddern folders) and starting with an |
123
|
|
|
|
|
|
|
underscore character. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (C) Bernie Simon. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
132
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Bernie Simon E<lt>bernie.simon@gmail.comE<gt> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |