Changeset 24558
- Timestamp:
- Jun 25, 2009, 2:29:18 PM (17 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 4 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Server.pm (modified) (2 diffs)
-
lib/Nebulous/Server/SQL.pm (modified) (1 diff)
-
t/13_server_find_objects.t (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r24545 r24558 29 29 - infinitely try to get a db handle if the connection fails 30 30 - add --mountpoint param to neb-voladd 31 - change Nebulous::Server->find_objects() to return dirs and to sort it's 32 output 31 33 32 34 0.16 -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r24548 r24558 1449 1449 } 1450 1450 1451 eval { 1452 $log->debug("trying for a directory match under dir: $dir_id"); 1451 # find dirs under dir 1452 my @dir_keys; 1453 eval { 1454 $log->debug("looking for directories under dir: $dir_id"); 1455 my $query = $db->prepare_cached( $sql->find_dir_by_parent_id); 1456 $query->execute( $dir_id ); 1457 1458 while ( my $row = $query->fetchrow_hashref ) { 1459 next if $row->{'dir_id'} == 1; 1460 my $dir = $row->{'dirname'}; 1461 if ($dir_id == 1) { 1462 push @keys, $dir . '/' if $dir; 1463 } else { 1464 push @keys, $key->path . '/' . $dir . '/' if $dir; 1465 } 1466 $log->debug( "matched $dir" ) if $dir; 1467 } 1468 }; 1469 $log->logdie("database error: $@") if $@; 1470 1471 # find files under dir 1472 eval { 1473 $log->debug("looking for objects under dir: $dir_id"); 1453 1474 my $query = $db->prepare_cached( $sql->find_object_by_dir_id ); 1454 1475 $query->execute( $dir_id ); … … 1463 1484 1464 1485 $log->debug( "leaving" ); 1465 1466 return \@keys;1486 1487 return [sort(@dir_keys), sort(@keys)]; 1467 1488 } 1468 1489 -
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r24545 r24558 317 317 FROM storage_object 318 318 WHERE dir_id = ? 319 }, 320 find_dir_by_parent_id => qq{ 321 SELECT dir_id, dirname 322 FROM directory 323 WHERE parent_id = ? 319 324 }, 320 325 rename_object => qq{ -
trunk/Nebulous-Server/t/13_server_find_objects.t
r24356 r24558 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 28;10 use Test::More tests => 36; 11 11 12 12 use lib qw( ./t ./lib ); … … 100 100 my $keys = $neb->find_objects("a"); 101 101 102 is(scalar @$keys, 1, 'number of keys found'); 103 is($keys->[0], "a/foo", "key name"); 102 is(scalar @$keys, 2, 'number of keys found'); 103 is($keys->[0], "a/b/", "key name"); 104 is($keys->[1], "a/foo", "key name"); 104 105 } 105 106 … … 113 114 114 115 is(scalar @$keys, 2, 'number of keys found'); 115 is($keys->[0], "a/ foo", "key name");116 is($keys->[1], "a/ bar", "key name");116 is($keys->[0], "a/bar", "key name"); 117 is($keys->[1], "a/foo", "key name"); 117 118 } 118 119 … … 138 139 my $keys = $neb->find_objects("/"); 139 140 140 is(scalar @$keys, 2, 'number of keys found');141 is($keys->[0], " foo", "key name");141 is(scalar @$keys, 3, 'number of keys found'); 142 is($keys->[0], "a/", "key name"); 142 143 is($keys->[1], "bar", "key name"); 144 is($keys->[2], "foo", "key name"); 143 145 } 144 146 … … 152 154 my $keys = $neb->find_objects("."); 153 155 154 is(scalar @$keys, 2, 'number of keys found');155 is($keys->[0], " foo", "key name");156 is(scalar @$keys, 3, 'number of keys found'); 157 is($keys->[0], "a/", "key name"); 156 158 is($keys->[1], "bar", "key name"); 159 is($keys->[2], "foo", "key name"); 157 160 } 158 161 … … 166 169 my $keys = $neb->find_objects(".."); 167 170 168 is(scalar @$keys, 2, 'number of keys found');169 is($keys->[0], " foo", "key name");171 is(scalar @$keys, 3, 'number of keys found'); 172 is($keys->[0], "a/", "key name"); 170 173 is($keys->[1], "bar", "key name"); 174 is($keys->[2], "foo", "key name"); 175 } 176 177 Test::Nebulous->setup; 178 179 { 180 $neb->create_object("a/bar"); 181 $neb->create_object("b/foo"); 182 $neb->create_object("foo"); 183 184 my $keys = $neb->find_objects("/"); 185 186 is(scalar @$keys, 3, 'number of keys found'); 187 is($keys->[0], "a/", "key name"); 188 is($keys->[1], "b/", "key name"); 189 is($keys->[2], "foo", "key name"); 171 190 } 172 191
Note:
See TracChangeset
for help on using the changeset viewer.
