| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Toader::Entry::Cache; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
38
|
use warnings; |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
267
|
|
|
4
|
7
|
|
|
7
|
|
39
|
use strict; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
160
|
|
|
5
|
7
|
|
|
7
|
|
38
|
use Toader::isaToaderDir; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
161
|
|
|
6
|
7
|
|
|
7
|
|
35
|
use base 'Error::Helper'; |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
479
|
|
|
7
|
7
|
|
|
7
|
|
38
|
use Toader::pathHelper; |
|
|
7
|
|
|
|
|
17
|
|
|
|
7
|
|
|
|
|
162
|
|
|
8
|
7
|
|
|
7
|
|
34
|
use Toader::Entry::Manage; |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
214
|
|
|
9
|
7
|
|
|
7
|
|
71
|
use Toader::Entry::Helper; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
179
|
|
|
10
|
7
|
|
|
7
|
|
16729
|
use DBI; |
|
|
7
|
|
|
|
|
133495
|
|
|
|
7
|
|
|
|
|
20670
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Toader::Entry::Cache - Misc helper methods for entries. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 0.0.0 |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.0.0'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 new |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This initializes this object. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
On argument is required and it is a L object. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $foo = Toader::Entry::Cache->new( $toader ); |
|
33
|
|
|
|
|
|
|
if($foo->error){ |
|
34
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub new{ |
|
40
|
0
|
|
|
0
|
1
|
|
my $toader=$_[1]; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $self={ |
|
43
|
|
|
|
|
|
|
error=>undef, |
|
44
|
|
|
|
|
|
|
errorString=>'', |
|
45
|
|
|
|
|
|
|
dir=>undef, |
|
46
|
|
|
|
|
|
|
edir=>undef, |
|
47
|
|
|
|
|
|
|
isatd=>Toader::isaToaderDir->new, |
|
48
|
|
|
|
|
|
|
VCSusable=>0, |
|
49
|
|
|
|
|
|
|
toader=>undef, |
|
50
|
|
|
|
|
|
|
errorExtra=>{ |
|
51
|
|
|
|
|
|
|
flags=>{ |
|
52
|
|
|
|
|
|
|
1=>'noToaderObj', |
|
53
|
|
|
|
|
|
|
2=>'notAtoaderObj', |
|
54
|
|
|
|
|
|
|
3=>'manageNewErrored', |
|
55
|
|
|
|
|
|
|
4=>'getVCSerrored', |
|
56
|
|
|
|
|
|
|
5=>'VCSusableErrored', |
|
57
|
|
|
|
|
|
|
6=>'noDirSpecified', |
|
58
|
|
|
|
|
|
|
7=>'notAtoaderDir', |
|
59
|
|
|
|
|
|
|
8=>'noDirSet', |
|
60
|
|
|
|
|
|
|
9=>'noEntrySpecified', |
|
61
|
|
|
|
|
|
|
10=>'notAtoaderEntryObj', |
|
62
|
|
|
|
|
|
|
11=>'DBIinitErrored', |
|
63
|
|
|
|
|
|
|
12=>'DBIdoErr', |
|
64
|
|
|
|
|
|
|
13=>'manageSetDirErrored', |
|
65
|
|
|
|
|
|
|
14=>'manageListErrored', |
|
66
|
|
|
|
|
|
|
15=>'manageReadErrored', |
|
67
|
|
|
|
|
|
|
16=>'noEntryNameSpecified', |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
}, |
|
70
|
|
|
|
|
|
|
}; |
|
71
|
0
|
|
|
|
|
|
bless $self; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#if we have a Toader object, reel it in |
|
74
|
0
|
0
|
|
|
|
|
if ( ! defined( $toader ) ){ |
|
75
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
76
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
77
|
0
|
|
|
|
|
|
$self->{errorString}='No Toader object specified'; |
|
78
|
0
|
|
|
|
|
|
$self->warn; |
|
79
|
0
|
|
|
|
|
|
return $self; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
0
|
|
|
|
|
if ( ref( $toader ) ne "Toader" ){ |
|
82
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
83
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
84
|
0
|
|
|
|
|
|
$self->{errorString}='The object specified is a "'.ref($toader).'"'; |
|
85
|
0
|
|
|
|
|
|
$self->warn; |
|
86
|
0
|
|
|
|
|
|
return $self; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
0
|
|
|
|
|
|
$self->{toader}=$toader; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#init the helper |
|
91
|
0
|
|
|
|
|
|
$self->{helper}=Toader::Entry::Helper->new( $self->{toader} ); |
|
92
|
0
|
0
|
|
|
|
|
if ( $self->{helper}->error ){ |
|
93
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
94
|
0
|
|
|
|
|
|
$self->{error}=18; |
|
95
|
|
|
|
|
|
|
$self->{errorString}='Failed to initialize Toader::Entry::Helper.'. |
|
96
|
0
|
|
|
|
|
|
'error="'.$self->{helper}->error.'" errorString="'.$self->{helper}->errorString.'"'; |
|
97
|
0
|
|
|
|
|
|
$self->warn; |
|
98
|
0
|
|
|
|
|
|
return $self; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#gets the Toader::VCS object |
|
102
|
0
|
|
|
|
|
|
$self->{vcs}=$self->{toader}->getVCS; |
|
103
|
0
|
0
|
|
|
|
|
if ( $toader->error ){ |
|
104
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
105
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
106
|
|
|
|
|
|
|
$self->{errorString}='Toader->getVCS errored. error="'. |
|
107
|
0
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
|
108
|
0
|
|
|
|
|
|
$self->warn; |
|
109
|
0
|
|
|
|
|
|
return $self; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#checks if VCS is usable |
|
113
|
0
|
|
|
|
|
|
$self->{VCSusable}=$self->{vcs}->usable; |
|
114
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
115
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
116
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
117
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->usable errored. error="'. |
|
118
|
0
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
|
119
|
0
|
|
|
|
|
|
$self->warn; |
|
120
|
0
|
|
|
|
|
|
return $self; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return $self; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 cachefile |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This returns the SQLite file that contains the cache for this directory. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $cacheFile=$foo->cachefile; |
|
131
|
|
|
|
|
|
|
if($foo->error){ |
|
132
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub cachefile{ |
|
138
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#blank any previous errors |
|
141
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
142
|
0
|
|
|
|
|
|
return undef; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#make sure a directory is defined |
|
146
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
147
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
148
|
0
|
|
|
|
|
|
$self->{errorString}='No dir set'; |
|
149
|
0
|
|
|
|
|
|
$self->warn; |
|
150
|
0
|
|
|
|
|
|
return undef; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
return $self->{cachefile}; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 connect |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This connect to the SQLite database containing |
|
159
|
|
|
|
|
|
|
the cache and returns the database handler. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $dbh=$foo->connect; |
|
162
|
|
|
|
|
|
|
if($foo->error){ |
|
163
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub connect{ |
|
170
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
#blank any previous errors |
|
173
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
174
|
0
|
|
|
|
|
|
return undef; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
#make sure a directory is defined |
|
178
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
179
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
180
|
0
|
|
|
|
|
|
$self->{errorString}='No dir set'; |
|
181
|
0
|
|
|
|
|
|
$self->warn; |
|
182
|
0
|
|
|
|
|
|
return undef; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
#return the stored dbh if it exists |
|
186
|
0
|
0
|
|
|
|
|
if ( defined( $self->{dbh} ) ){ |
|
187
|
0
|
|
|
|
|
|
return $self->{dbh}; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
#connect the database if needed |
|
191
|
0
|
|
|
|
|
|
my $dbh=DBI->connect( 'dbi:SQLite:dbname='.$self->cachefile, "", "" ); |
|
192
|
0
|
0
|
|
|
|
|
if ( ! defined( $dbh ) ){ |
|
193
|
0
|
|
|
|
|
|
$self->{error}=11; |
|
194
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->connect failed. err="'.DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
195
|
0
|
|
|
|
|
|
$self->warn; |
|
196
|
0
|
|
|
|
|
|
return undef; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
0
|
|
|
|
|
|
$self->{dbh}=$dbh; |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#init... checks if it needs initialized... |
|
201
|
0
|
|
|
|
|
|
$self->init; |
|
202
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
203
|
0
|
|
|
|
|
|
$self->warnString('Need to init the cache, but failed'); |
|
204
|
0
|
|
|
|
|
|
return undef; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
return $dbh; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 deleteEntry |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Deletes a specified entry from the cache. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
One argument is taken and the is the name of the entry. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
$foo->deleteEntry( $entryName ); |
|
217
|
|
|
|
|
|
|
if($foo->error){ |
|
218
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub deleteEntry{ |
|
224
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
225
|
0
|
|
|
|
|
|
my $entryName=$_[1]; |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
#blank any previous errors |
|
228
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
229
|
0
|
|
|
|
|
|
return undef; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
#make sure we have an entry |
|
233
|
0
|
0
|
|
|
|
|
if ( ! defined ( $entryName ) ){ |
|
234
|
0
|
|
|
|
|
|
$self->{error}=16; |
|
235
|
0
|
|
|
|
|
|
$self->{errorString}='No entryName specified'; |
|
236
|
0
|
|
|
|
|
|
$self->warn; |
|
237
|
0
|
|
|
|
|
|
return undef; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
#gets the DBH to use |
|
241
|
0
|
|
|
|
|
|
my $dbh=$self->connect; |
|
242
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
243
|
0
|
|
|
|
|
|
$self->warnString('Failed to get the DBH via $self->connect'); |
|
244
|
0
|
|
|
|
|
|
return undef; |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
#delete it if it exists |
|
248
|
0
|
|
|
|
|
|
my $sql='DELETE FROM Entries WHERE entry=?;'; |
|
249
|
0
|
|
|
|
|
|
$dbh->do( $sql, undef, $entryName ); |
|
250
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
251
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
252
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$sql.'") failed. err="'. |
|
253
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
254
|
0
|
|
|
|
|
|
$self->warn; |
|
255
|
0
|
|
|
|
|
|
return undef; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
#remove any old tags |
|
259
|
0
|
|
|
|
|
|
$sql='DELETE FROM Tags WHERE entry=?;'; |
|
260
|
0
|
|
|
|
|
|
$dbh->do( $sql, undef, $entryName ); |
|
261
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
262
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
263
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$sql.'") failed. err="'. |
|
264
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
265
|
0
|
|
|
|
|
|
$self->warn; |
|
266
|
0
|
|
|
|
|
|
return undef; |
|
267
|
|
|
|
|
|
|
} |
|
268
|
|
|
|
|
|
|
|
|
269
|
0
|
|
|
|
|
|
return 1; |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 disconnect |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This disconnect from the SQLite database containing |
|
275
|
|
|
|
|
|
|
the cache and returns the database handler. |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
my $dbh=$foo->connect; |
|
278
|
|
|
|
|
|
|
if($foo->error){ |
|
279
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub disconnect{ |
|
285
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
#blank any previous errors |
|
288
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
289
|
0
|
|
|
|
|
|
return undef; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
#make sure a directory is defined |
|
293
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
294
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
295
|
0
|
|
|
|
|
|
$self->{errorString}='No dir set'; |
|
296
|
0
|
|
|
|
|
|
$self->warn; |
|
297
|
0
|
|
|
|
|
|
return undef; |
|
298
|
|
|
|
|
|
|
} |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
#if there is no stored dbh, we are good |
|
301
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dbh} ) ){ |
|
302
|
0
|
|
|
|
|
|
return 1; |
|
303
|
|
|
|
|
|
|
} |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
#disconnects and removes the handler |
|
306
|
0
|
|
|
|
|
|
$self->{dbh}->disconnect; |
|
307
|
0
|
|
|
|
|
|
delete( $self->{dbh} ); |
|
308
|
|
|
|
|
|
|
|
|
309
|
0
|
|
|
|
|
|
return 1; |
|
310
|
|
|
|
|
|
|
} |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head2 init |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
This checks if the cache needs initialized for the directory. If it |
|
315
|
|
|
|
|
|
|
does need initialized it will do so. |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
$foo->init |
|
318
|
|
|
|
|
|
|
if($foo->error){ |
|
319
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
320
|
|
|
|
|
|
|
} |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=cut |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub init{ |
|
325
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
#blank any previous errors |
|
328
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
329
|
0
|
|
|
|
|
|
return undef; |
|
330
|
|
|
|
|
|
|
} |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
#make sure a directory is defined |
|
333
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
334
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
335
|
0
|
|
|
|
|
|
$self->{errorString}='No dir set'; |
|
336
|
0
|
|
|
|
|
|
$self->warn; |
|
337
|
0
|
|
|
|
|
|
return undef; |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
#cache exists |
|
341
|
0
|
0
|
|
|
|
|
if ( -f $self->{cachefile} ){ |
|
342
|
0
|
|
|
|
|
|
return 1; |
|
343
|
|
|
|
|
|
|
} |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
#if VCS is not usable, stop here |
|
346
|
0
|
0
|
|
|
|
|
if ( ! $self->{VCSusable} ){ |
|
347
|
0
|
|
|
|
|
|
return 1; |
|
348
|
|
|
|
|
|
|
} |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
#initialize it as it has not been created |
|
351
|
0
|
|
|
|
|
|
$self->reinit; |
|
352
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
353
|
0
|
|
|
|
|
|
$self->warnString( 'Failed to call reinit' ); |
|
354
|
0
|
|
|
|
|
|
return undef; |
|
355
|
|
|
|
|
|
|
} |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
#if it is under VCS, we have nothing to do |
|
358
|
0
|
|
|
|
|
|
my $underVCS=$self->{vcs}->underVCS( $self->cachefile ); |
|
359
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
360
|
0
|
|
|
|
|
|
$self->{error}=17; |
|
361
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->underVCS errored. error="'. |
|
362
|
0
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
|
363
|
0
|
|
|
|
|
|
$self->warn; |
|
364
|
0
|
|
|
|
|
|
return undef; |
|
365
|
|
|
|
|
|
|
} |
|
366
|
0
|
0
|
|
|
|
|
if ( $underVCS ){ |
|
367
|
0
|
|
|
|
|
|
return 1; |
|
368
|
|
|
|
|
|
|
} |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
#add it as if we reach here it is not under VCS and VCS is being used |
|
371
|
0
|
|
|
|
|
|
$self->{vcs}->add( $self->cachefile ); |
|
372
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
373
|
0
|
|
|
|
|
|
$self->{error}=18; |
|
374
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->add errored. error="'. |
|
375
|
0
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
|
376
|
0
|
|
|
|
|
|
$self->warn; |
|
377
|
0
|
|
|
|
|
|
return undef; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
0
|
|
|
|
|
|
return 1; |
|
381
|
|
|
|
|
|
|
} |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=head2 reinit |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
Re-initializes the SQLite database. This will |
|
386
|
|
|
|
|
|
|
connect to it, drop the tables, and then recreate |
|
387
|
|
|
|
|
|
|
the tables. |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
$foo->reinit; |
|
390
|
|
|
|
|
|
|
if($foo->error){ |
|
391
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
392
|
|
|
|
|
|
|
} |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=cut |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
sub reinit{ |
|
397
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
398
|
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
#blank any previous errors |
|
400
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
401
|
0
|
|
|
|
|
|
return undef; |
|
402
|
|
|
|
|
|
|
} |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
#make sure a directory is defined |
|
405
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
406
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
407
|
0
|
|
|
|
|
|
$self->{errorString}='No dir set'; |
|
408
|
0
|
|
|
|
|
|
$self->warn; |
|
409
|
0
|
|
|
|
|
|
return undef; |
|
410
|
|
|
|
|
|
|
} |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
#connects to the database |
|
413
|
0
|
|
|
|
|
|
my $dbh=$self->connect; |
|
414
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
415
|
0
|
|
|
|
|
|
$self->warnString(); |
|
416
|
0
|
|
|
|
|
|
return undef; |
|
417
|
|
|
|
|
|
|
} |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
#drops the Tags table |
|
420
|
0
|
|
|
|
|
|
my $do="DROP TABLE IF EXISTS Tags;"; |
|
421
|
0
|
|
|
|
|
|
$dbh->do( $do ); |
|
422
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
423
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
424
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$do.'") failed. err="'. |
|
425
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
426
|
0
|
|
|
|
|
|
$self->warn; |
|
427
|
0
|
|
|
|
|
|
return undef; |
|
428
|
|
|
|
|
|
|
} |
|
429
|
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
#create the Tags table |
|
431
|
0
|
|
|
|
|
|
$do="CREATE TABLE Tags( entry TEXT, tag TEXT );"; |
|
432
|
0
|
|
|
|
|
|
$dbh->do( $do ); |
|
433
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
434
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
435
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$do.'") failed. err="'. |
|
436
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
437
|
0
|
|
|
|
|
|
$self->warn; |
|
438
|
0
|
|
|
|
|
|
return undef; |
|
439
|
|
|
|
|
|
|
} |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
#drop the Entries table |
|
442
|
0
|
|
|
|
|
|
$do="DROP TABLE IF EXISTS Entries;"; |
|
443
|
0
|
|
|
|
|
|
$dbh->do( $do ); |
|
444
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
445
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
446
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$do.'") failed. err="'. |
|
447
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
448
|
0
|
|
|
|
|
|
$self->warn; |
|
449
|
0
|
|
|
|
|
|
return undef; |
|
450
|
|
|
|
|
|
|
} |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
#create the Entries table |
|
453
|
0
|
|
|
|
|
|
$do="CREATE TABLE Entries( entry TEXT PRIMARY KEY, renderer TEXT, title TEXT, summary TEXT, From TEXT, publish INT );"; |
|
454
|
0
|
|
|
|
|
|
$dbh->do( $do ); |
|
455
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
456
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
457
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$do.'") failed. err="'. |
|
458
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
459
|
0
|
|
|
|
|
|
$self->warn; |
|
460
|
0
|
|
|
|
|
|
return undef; |
|
461
|
|
|
|
|
|
|
} |
|
462
|
|
|
|
|
|
|
|
|
463
|
0
|
|
|
|
|
|
return 1; |
|
464
|
|
|
|
|
|
|
} |
|
465
|
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=head2 setDir |
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
This sets the directory to operate on. |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
One argument is required. It is the directory to use. |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
$foo->setDir($directory); |
|
473
|
|
|
|
|
|
|
if($foo->error){ |
|
474
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
475
|
|
|
|
|
|
|
} |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=cut |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
sub setDir{ |
|
480
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
481
|
0
|
|
|
|
|
|
my $directory=$_[1]; |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
#blank any previous errors |
|
484
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
485
|
0
|
|
|
|
|
|
return undef; |
|
486
|
|
|
|
|
|
|
} |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
#error if no directory is specified |
|
489
|
0
|
0
|
|
|
|
|
if (!defined( $directory )) { |
|
490
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
491
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
492
|
0
|
|
|
|
|
|
$self->warn; |
|
493
|
0
|
|
|
|
|
|
return undef; |
|
494
|
|
|
|
|
|
|
} |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
#cleans up the naming |
|
497
|
0
|
|
|
|
|
|
my $pathHelper=Toader::pathHelper->new( $directory ); |
|
498
|
0
|
|
|
|
|
|
$directory=$pathHelper->cleanup( $directory ); |
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
#make sure it is a Toader directory |
|
501
|
0
|
|
|
|
|
|
my $tdc=Toader::isaToaderDir->new; |
|
502
|
0
|
|
|
|
|
|
my $isaToaderDir=$tdc->isaToaderDir($directory); |
|
503
|
0
|
0
|
|
|
|
|
if ( ! $isaToaderDir ) { |
|
504
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
505
|
0
|
|
|
|
|
|
$self->{errorString}='Not a Toader directory according to Toader::isaToaderDir->isaToaderDir '; |
|
506
|
0
|
|
|
|
|
|
$self->warn; |
|
507
|
0
|
|
|
|
|
|
return undef; |
|
508
|
|
|
|
|
|
|
} |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
#delete the dbh if needed |
|
511
|
0
|
0
|
|
|
|
|
if ( defined( $self->{dbh} ) ){ |
|
512
|
0
|
|
|
|
|
|
$self->{dbh}->disconnect; |
|
513
|
0
|
|
|
|
|
|
delete( $self->{dbh} ); |
|
514
|
|
|
|
|
|
|
} |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
#save the directory |
|
517
|
0
|
|
|
|
|
|
$self->{dir}=$directory; |
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
#sets the cache file |
|
520
|
0
|
|
|
|
|
|
$self->{cachefile}=$self->{helper}->entryDirectory.'/cache.sqlite'; |
|
521
|
|
|
|
|
|
|
|
|
522
|
0
|
|
|
|
|
|
return 1; |
|
523
|
|
|
|
|
|
|
} |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=head2 updateAll |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
Updates the cache for all entries in that directory. |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
$foo->updateAll; |
|
530
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
531
|
|
|
|
|
|
|
warn( 'error:'.$foo->error.':'.$foo->errorString ); |
|
532
|
|
|
|
|
|
|
} |
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
=cut |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
sub updateAll{ |
|
537
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
#blank any previous errors |
|
540
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
541
|
0
|
|
|
|
|
|
return undef; |
|
542
|
|
|
|
|
|
|
} |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
#make sure a directory is defined |
|
545
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
546
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
547
|
0
|
|
|
|
|
|
$self->{errorString}='No dir set'; |
|
548
|
0
|
|
|
|
|
|
$self->warn; |
|
549
|
0
|
|
|
|
|
|
return undef; |
|
550
|
|
|
|
|
|
|
} |
|
551
|
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
#gets the entry manager |
|
553
|
0
|
|
|
|
|
|
my $em=Toader::Entry::Manage->new( $self->{toader} ); |
|
554
|
0
|
0
|
|
|
|
|
if ( $em->error ){ |
|
555
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
556
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to invoke Toader::Entry::Manage->new. error="'.$em->error. |
|
557
|
|
|
|
|
|
|
'" errorFlag="'.$em->errorFlag.'" errorString="'.$em->errorString.'"'; |
|
558
|
0
|
|
|
|
|
|
$self->warn; |
|
559
|
0
|
|
|
|
|
|
return undef; |
|
560
|
|
|
|
|
|
|
} |
|
561
|
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
#sets the directory for the manager |
|
563
|
0
|
|
|
|
|
|
$em->setDir( $self->{dir} ); |
|
564
|
0
|
0
|
|
|
|
|
if ( $em->error ){ |
|
565
|
0
|
|
|
|
|
|
$self->{error}=13; |
|
566
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to invoke Toader::Entry::Manage->setDir. error="'.$em->error. |
|
567
|
|
|
|
|
|
|
'" errorFlag="'.$em->errorFlag.'" errorString="'.$em->errorString.'"'; |
|
568
|
0
|
|
|
|
|
|
$self->warn; |
|
569
|
0
|
|
|
|
|
|
return undef; |
|
570
|
|
|
|
|
|
|
} |
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
#gets a list of all the entries |
|
573
|
0
|
|
|
|
|
|
my @entries=$em->list; |
|
574
|
0
|
0
|
|
|
|
|
if ( $em->error ){ |
|
575
|
0
|
|
|
|
|
|
$self->{error}=14; |
|
576
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to invoke Toader::Entry::Manage->list. error="'.$em->error. |
|
577
|
|
|
|
|
|
|
'" errorFlag="'.$em->errorFlag.'" errorString="'.$em->errorString.'"'; |
|
578
|
0
|
|
|
|
|
|
$self->warn; |
|
579
|
0
|
|
|
|
|
|
return undef; |
|
580
|
|
|
|
|
|
|
} |
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
#go through each one |
|
583
|
0
|
|
|
|
|
|
my $int=0; |
|
584
|
0
|
|
|
|
|
|
while ( defined $entries[$int] ){ |
|
585
|
|
|
|
|
|
|
#gets the entry |
|
586
|
0
|
|
|
|
|
|
my $entry=$em->read( $entries[$int] ); |
|
587
|
0
|
0
|
|
|
|
|
if ( $em->error ){ |
|
588
|
0
|
|
|
|
|
|
$self->{error}=15; |
|
589
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to invoke Toader::Entry::Manage->read. error="'.$em->error. |
|
590
|
|
|
|
|
|
|
'" errorFlag="'.$em->errorFlag.'" errorString="'.$em->errorString.'"'; |
|
591
|
0
|
|
|
|
|
|
$self->warn; |
|
592
|
0
|
|
|
|
|
|
return undef; |
|
593
|
|
|
|
|
|
|
} |
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
#updates the cache for the entry |
|
596
|
0
|
|
|
|
|
|
$self->updateEntry( $entry ); |
|
597
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
598
|
0
|
|
|
|
|
|
$self->warnString('updateEntry errored for "'.$entries[$int].'"'); |
|
599
|
|
|
|
|
|
|
return undef |
|
600
|
0
|
|
|
|
|
|
} |
|
601
|
|
|
|
|
|
|
|
|
602
|
0
|
|
|
|
|
|
$int++; |
|
603
|
|
|
|
|
|
|
} |
|
604
|
|
|
|
|
|
|
|
|
605
|
0
|
|
|
|
|
|
return 1; |
|
606
|
|
|
|
|
|
|
} |
|
607
|
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=head2 updateEntry |
|
609
|
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
Updates the cache for the passed entry. |
|
611
|
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
One argument is taken and that is the Toader::Entry object that |
|
613
|
|
|
|
|
|
|
the cache is being updated for. |
|
614
|
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
$foo->updateEntry( $entry ); |
|
616
|
|
|
|
|
|
|
if($foo->error){ |
|
617
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
618
|
|
|
|
|
|
|
} |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=cut |
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
sub updateEntry{ |
|
623
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
624
|
0
|
|
|
|
|
|
my $entry=$_[1]; |
|
625
|
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
#blank any previous errors |
|
627
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
628
|
0
|
|
|
|
|
|
return undef; |
|
629
|
|
|
|
|
|
|
} |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
#make sure we have an entry |
|
632
|
0
|
0
|
|
|
|
|
if ( ! defined ( $entry ) ){ |
|
633
|
0
|
|
|
|
|
|
$self->{error}=9; |
|
634
|
0
|
|
|
|
|
|
$self->{errorString}='No entry specified'; |
|
635
|
0
|
|
|
|
|
|
$self->warn; |
|
636
|
0
|
|
|
|
|
|
return undef; |
|
637
|
|
|
|
|
|
|
} |
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
#make sure we have a Toader::Entry object |
|
640
|
0
|
0
|
|
|
|
|
if ( ref( $entry ) ne "Toader::Entry" ){ |
|
641
|
0
|
|
|
|
|
|
$self->{error}=10; |
|
642
|
0
|
|
|
|
|
|
$self->{errorString}='Not a Toader::Entry object'; |
|
643
|
0
|
|
|
|
|
|
$self->warn; |
|
644
|
0
|
|
|
|
|
|
return undef; |
|
645
|
|
|
|
|
|
|
} |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
#make sure a directory is defined |
|
648
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
649
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
650
|
0
|
|
|
|
|
|
$self->{errorString}='No dir set'; |
|
651
|
0
|
|
|
|
|
|
$self->warn; |
|
652
|
0
|
|
|
|
|
|
return undef; |
|
653
|
|
|
|
|
|
|
} |
|
654
|
|
|
|
|
|
|
|
|
655
|
0
|
|
|
|
|
|
my $entryID=$entry->entryNameGet; |
|
656
|
0
|
|
|
|
|
|
my $renderer=$entry->rendererGet; |
|
657
|
0
|
|
|
|
|
|
my $title=$entry->titleGet; |
|
658
|
0
|
|
|
|
|
|
my $summary=$entry->summaryGet; |
|
659
|
0
|
|
|
|
|
|
my $From=$entry->fromGet; |
|
660
|
0
|
|
|
|
|
|
my $publish=$entry->publishGet; |
|
661
|
0
|
|
|
|
|
|
my @tags=$entry->tagsGet; |
|
662
|
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
#gets the DBH to use |
|
664
|
0
|
|
|
|
|
|
my $dbh=$self->connect; |
|
665
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
666
|
0
|
|
|
|
|
|
$self->warnString('Failed to get the DBH via $self->connect'); |
|
667
|
0
|
|
|
|
|
|
return undef; |
|
668
|
|
|
|
|
|
|
} |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
#delete it if it exists |
|
671
|
0
|
|
|
|
|
|
my $sql='DELETE FROM Entries WHERE entry=?;'; |
|
672
|
0
|
|
|
|
|
|
$dbh->do( $sql, undef, $entryID ); |
|
673
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
674
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
675
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$sql.'") failed. err="'. |
|
676
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
677
|
0
|
|
|
|
|
|
$self->warn; |
|
678
|
0
|
|
|
|
|
|
return undef; |
|
679
|
|
|
|
|
|
|
} |
|
680
|
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
#adds it |
|
682
|
0
|
|
|
|
|
|
$sql='INSERT INTO Entries ( entry, renderer, title, summary, From, publish ) values ( ?, ?, ?, ?, ?, ? );'; |
|
683
|
0
|
|
|
|
|
|
$dbh->do( $sql, undef, $entryID, $renderer, $title, $summary, $From, $publish ); |
|
684
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
685
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
686
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$sql.'") failed. err="'. |
|
687
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
688
|
0
|
|
|
|
|
|
$self->warn; |
|
689
|
0
|
|
|
|
|
|
return undef; |
|
690
|
|
|
|
|
|
|
} |
|
691
|
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
#remove any old tags |
|
693
|
0
|
|
|
|
|
|
$sql='DELETE FROM Tags WHERE entry=?;'; |
|
694
|
0
|
|
|
|
|
|
$dbh->do( $sql, undef, $entryID ); |
|
695
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
696
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
697
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$sql.'") failed. err="'. |
|
698
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
699
|
0
|
|
|
|
|
|
$self->warn; |
|
700
|
0
|
|
|
|
|
|
return undef; |
|
701
|
|
|
|
|
|
|
} |
|
702
|
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
#processes each tag |
|
704
|
0
|
|
|
|
|
|
my $int=0; |
|
705
|
0
|
|
|
|
|
|
while( defined( $tags[ $int ] ) ){ |
|
706
|
|
|
|
|
|
|
#add the tag for that entry |
|
707
|
0
|
|
|
|
|
|
$sql='INSERT INTO Tags ( entry, tag ) VALUES ( ?, ? );'; |
|
708
|
0
|
|
|
|
|
|
$dbh->do( $sql, undef, $entryID, $tags[ $int ] ); |
|
709
|
0
|
0
|
|
|
|
|
if ( $dbh->err ){ |
|
710
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
711
|
0
|
|
|
|
|
|
$self->{errorString}='DBI->do("'.$sql.'") failed. err="'. |
|
712
|
|
|
|
|
|
|
DBI::err.'" errstr="'.DBI::errstr.'"'; |
|
713
|
0
|
|
|
|
|
|
$self->warn; |
|
714
|
0
|
|
|
|
|
|
return undef; |
|
715
|
|
|
|
|
|
|
} |
|
716
|
|
|
|
|
|
|
|
|
717
|
0
|
|
|
|
|
|
$int++; |
|
718
|
|
|
|
|
|
|
} |
|
719
|
|
|
|
|
|
|
|
|
720
|
0
|
|
|
|
|
|
return 1; |
|
721
|
|
|
|
|
|
|
} |
|
722
|
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
=head1 ERROR CODES/Flags |
|
724
|
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
=head2 1, noToaderObj |
|
726
|
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
The object supplied for the L object. |
|
728
|
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
=head2 2, notAtoaderObj |
|
730
|
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
The supplies object is not a L object. |
|
732
|
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
=head2 3, manageNewErrored |
|
734
|
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
L->new errored. |
|
736
|
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
=head2 4, getVCSerrored |
|
738
|
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
Failed to get L object. |
|
740
|
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
=head2 5, VCSusableErrored |
|
742
|
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
L->usable errored. |
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
=head2 6, noDirSpecified |
|
746
|
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
Nothing was passed as a directory. |
|
748
|
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
=head2 7, notAtoaderDir |
|
750
|
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
The specified directory is not a L directory. |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=head2 8, noDirSet |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
No dir has been set yet. |
|
756
|
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
=head2 9, noEntrySpecified |
|
758
|
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
No entry was specified to processes. This needs to be a L object. |
|
760
|
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
=head2 10, notAtoaderEntryObj |
|
762
|
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
Not a L object. |
|
764
|
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
=head2 11, DBIinitErrored |
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
Failed to initialize the SQLite database via |
|
768
|
|
|
|
|
|
|
L->connect. |
|
769
|
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
=head2 12, DBIdoErr |
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
Error with L->do. |
|
773
|
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
=head2 13, manageSetDirErrored |
|
775
|
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
Failed when calling L->setDir. |
|
777
|
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
=head2 14, manageListErrored |
|
779
|
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
Failed when calling L->list. |
|
781
|
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
=head2 15, manageReadErrored |
|
783
|
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
Failed when calling L->read. |
|
785
|
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=head2 16, noEntryNameSpecified |
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
No entryName was specified to processes. This id different from noEntrySpecified |
|
789
|
|
|
|
|
|
|
as noEntrySpecified requires a L object and this just requires a |
|
790
|
|
|
|
|
|
|
entry name. |
|
791
|
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=head2 17, underVCS errored |
|
793
|
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
L->underVCS errored. |
|
795
|
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
=head2 18, VCSaddErrored |
|
797
|
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
L->add errored. |
|
799
|
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
=head1 AUTHOR |
|
801
|
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
803
|
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
=head1 BUGS |
|
805
|
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
807
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
808
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
809
|
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
=head1 SUPPORT |
|
811
|
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
813
|
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
perldoc Toader::Entry::Cache |
|
815
|
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
You can also look for information at: |
|
818
|
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=over 4 |
|
820
|
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
822
|
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
L |
|
824
|
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
826
|
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
L |
|
828
|
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
830
|
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
L |
|
832
|
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=item * Search CPAN |
|
834
|
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
L |
|
836
|
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=back |
|
838
|
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
841
|
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
844
|
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
Copyright 2014 Zane C. Bowers-Hadley. |
|
846
|
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
848
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
849
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
850
|
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
852
|
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=cut |
|
854
|
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
1; # End of Toader::Entry::Cache |