@@ -225,7 +225,7 @@ sub progress {
225
225
my $linked_asset = eval { WebGUI::Asset-> newPending($session , $shortcut -> get(' shortcutToAssetId' )); };
226
226
if ( $@ || Exception::Class-> caught() || ! $linked_asset ) {
227
227
printf " \r %-68s" , " -- Broken shortcut: " .$shortcut -> getId.' pointing to ' .$shortcut -> get(' shortcutToAssetId' );
228
- if ($fix || $ delete ) {
228
+ if ($delete ) {
229
229
my $success = $shortcut -> purge;
230
230
if ($success ) {
231
231
print " Purged shortcut" ;
@@ -242,6 +242,44 @@ sub progress {
242
242
progress( $shortcuts , $count ) unless $no_progress ;
243
243
}
244
244
245
+ print " \n " ;
246
+
247
+ my $file_assets = $session -> db-> quickScalar(q! select count(*) from asset where className like 'WebGUI::Asset::File%'! );
248
+ if ($file_assets ) {
249
+ print " Checking for broken File Assets\n " ;
250
+ my $get_asset = WebGUI::Asset::File-> getIsa($session , 0, {returnAll => 1});
251
+ $count = 0;
252
+ FILE_ASSET: while (1) {
253
+ my $file_asset = eval { $get_asset -> () };
254
+ if ( $@ || Exception::Class-> caught() ) {
255
+ # #Do nothing, since it would have been caught above
256
+ printf " \r %-68s" , " No asset to check" ;
257
+ }
258
+ elsif (!$file_asset ) {
259
+ last FILE_ASSET
260
+ }
261
+ else {
262
+ my $storage = $file_asset -> getStorageLocation;
263
+ my $file = $storage -> getPath($file_asset -> get(' filename' ));
264
+ if (! -e $file ) {
265
+ printf " \r %-s" , " -- Broken file asset: " .$file_asset -> getId." file does not exist: $file " ;
266
+ if ($delete ) {
267
+ my $success = $file_asset -> purge;
268
+ if ($success ) {
269
+ print " Purged File Asset" ;
270
+ }
271
+ else {
272
+ print " Could not purge File Asset" ;
273
+ }
274
+ }
275
+ print " \n " ;
276
+ }
277
+ }
278
+ progress( $file_assets , $count ++ ) unless $no_progress ;
279
+ }
280
+ progress( $file_assets , $count ) unless $no_progress ;
281
+ }
282
+
245
283
finish($session );
246
284
print " \n " ;
247
285
@@ -298,7 +336,20 @@ =head1 SYNOPSIS
298
336
=head1 DESCRIPTION
299
337
300
338
This utility will find any broken assets that cannot be instantiated and are
301
- causing undesired operation of your website.
339
+ causing undesired operation of your website. It also checks for these kinds of
340
+ semi-working assets and reports them:
341
+
342
+ =over 4
343
+
344
+ =item *
345
+
346
+ Shortcuts pointing to assets that don't exist.
347
+
348
+ =item *
349
+
350
+ File assets that have lost their files in the uploads area.
351
+
352
+ =back
302
353
303
354
It can also automatically delete them or fix them so you can restore missing data.
304
355
@@ -320,7 +371,7 @@ =head1 OPTIONS
320
371
321
372
=item B<--fix >
322
373
323
- Try to fix any corrupted assets.
374
+ Try to fix any corrupted assets. The broken Shortcuts and File Assets cannot be fixed.
324
375
325
376
=item B<--help >
326
377
0 commit comments