Changeset 5501 for trunk/Nebulous-Server
- Timestamp:
- Nov 10, 2005, 11:51:06 AM (21 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 1 added
- 2 edited
-
lib/Nebulous/Server.pm (modified) (4 diffs)
-
lib/Nebulous/Server/SQL.pm (modified) (2 diffs)
-
t/09_server_is_valid_volume_name.t (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r5498 r5501 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.1 4 2005-11-10 21:31:26 jhoblitt Exp $3 # $Id: Server.pm,v 1.15 2005-11-10 21:51:06 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 82 82 { 83 83 type => SCALAR, 84 callbacks => { 85 # check that the volume requested is valid 86 'is valid volume name' => sub { _is_valid_volume_name($_[0]) }, 87 }, 84 88 optional => 1, 85 89 }, … … 97 101 98 102 # check that the comment isn't too long 99 # check that the volume requested is valid100 103 101 104 my $uri; … … 702 705 } 703 706 707 sub _is_valid_volume_name { 708 my $vol_name = shift; 709 710 my $volume; 711 eval { 712 my $query = $db->prepare_cached( $sql->get_volume_by_name ); 713 $query->execute( $vol_name ); 714 ( $volume ) = $query->fetchrow_array; 715 716 $query->finish; 717 }; 718 if ( $@ ) { 719 $db->rollback; 720 $log->logdie( "database error: $@" ); 721 } 722 723 return ( defined $volume ) ? 1 : undef; 724 } 725 704 726 1; 705 727 -
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r5496 r5501 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1.1 5 2005-11-10 21:21:14jhoblitt Exp $3 # $Id: SQL.pm,v 1.16 2005-11-10 21:51:06 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 128 128 FROM class 129 129 WHERE class_id = ? 130 }, 131 get_volume_by_name => qq{ 132 SELECT vol_id, name, uri 133 FROM volume 134 WHERE name = ? 130 135 }, 131 136 );
Note:
See TracChangeset
for help on using the changeset viewer.
