Changeset 1755


Ignore:
Timestamp:
2000-12-07T11:45:39+13:00 (23 years ago)
Author:
say1
Message:

added better cycle detection (but still not perfect)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/RecPlug.pm

    r1710 r1755  
    6969
    7070    my (@dir, $subfile);
    71 
    7271    my $count = 0;
    7372
    74  
    7573    # see if this is a directory
    7674    my $dirname = &util::filename_cat ($base_dir, $file);
     75
     76    # check to make sure we're not reading our own archives
     77    # or index directory
     78    if ($dirname =~ m%^$ENV{'GSDLHOME'}/.*/import.*/(archives|index)$%) {
     79    print $outhandle "RecPlug: $dirname appears to be a reference to a Greenstone collection, skipping.\n";
     80    return 1;
     81    }
     82
     83    # check to see we haven't got a cyclic path...
     84    if ($dirname =~ m%(/.*){,41}%) {
     85    print $outhandle "RecPlug: $dirname is 40 directories deep, is this a recursive path? if not increase constant in RecPlug.pm.\n";
     86    return 1;
     87    }
     88
     89    # check to see we haven't got a cyclic path...
     90    if ($dirname =~ m%.*?import/(.+?)/import/\1.*%) {
     91    print $outhandle "RecPlug: $dirname appears to a recursive loop ...\n";
     92    return 1;
     93    }
     94
     95
    7796    if (-d $dirname) {
    7897
     98    if ($dirname =~ m|/CVS$|) {
     99        print $outhandle "RecPlug: $dirname is a CVS directory, skipping.\n";
     100        return 1;
     101    }
    79102    # read all the files in the directory
    80103        if (!opendir (DIR, $dirname))
     
    83106            return;
    84107        }
    85     if ($dirname =~ m|/CVS$|) {
    86         print $outhandle "RecPlug: $dirname is a CVS directory, skipping.\n";
    87         return 1;
    88     }
    89108
    90109    @dir = readdir (DIR);
Note: See TracChangeset for help on using the changeset viewer.