Changeset 762
- Timestamp:
- 03/08/07 20:43:58 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/filepaths-20070306/server/lib/MogileFS/Plugin/FilePaths.pm
r759 r762 14 14 use MogileFS::Worker::Query; 15 15 16 # FIXME: need to add in the configuration options for domain only17 18 16 # called when this plugin is loaded, this sub must return a true value in order for 19 17 # MogileFS to consider the plugin to have loaded successfully. if you return a 20 18 # non-true value, you MUST NOT install any handlers or other changes to the system. 21 19 # if you install something here, you MUST uninstall it in the unload sub. 20 21 sub _parse_path { 22 my $fullpath = shift; 23 return unless defined($fullpath) and length($fullpath); 24 my ($path, $file) = $fullpath =~ 25 m!^(/(?:[\w\-\.]+/)*)([\w\-\.]+)$!; 26 return ($path, $file); 27 } 28 22 29 sub load { 23 30 … … 27 34 my $args = shift; 28 35 return 1 unless _check_dmid($args->{dmid}); 29 delete $args->{key}; 36 37 my $fullpath = delete $args->{key}; 38 my ($path, $filename) = _parse_path($fullpath); 39 return 0 unless defined($path) && length($path) && defined($filename) && length($filename); 40 return 1; 30 41 }); 31 42 … … 52 63 53 64 # ensure we got a valid seeming path and filename 54 my ($path, $filename) = 55 ($args->{logical_path} =~ m!^(/(?:[\w\-\.]+/)*)([\w\-\.]+)$!) ? ($1, $2) : (undef, undef); 56 65 my ($path, $filename) = _parse_path($args->{logical_path}); 57 66 return 0 unless defined($path) && length($path) && defined($filename) && length($filename); 58 67 … … 85 94 86 95 # ensure we got a valid seeming path and filename 87 my ($path, $filename) = 88 ($args->{key} =~ m!^(/(?:[\w\-\.]+/)*)([\w\-\.]+)$!) ? ($1, $2) : (undef, undef); 89 return 0 unless $path && $filename; 96 my ($path, $filename) = _parse_path($args->{key}); 97 return 0 unless defined($path) && length($path) && defined($filename) && length($filename); 90 98 91 99 # now try to get the end of the path
