Changeset 23760
- Timestamp:
- Apr 8, 2009, 4:51:15 PM (17 years ago)
- Location:
- branches/neb_distrib_20081210/Nebulous-Server
- Files:
-
- 4 edited
-
lib/Nebulous/Server.pm (modified) (4 diffs)
-
lib/Nebulous/Server/SQL.pm (modified) (1 diff)
-
t/03_server_create_object.t (modified) (2 diffs)
-
t/13_server_rename_object.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server.pm
r23755 r23760 421 421 my $query = $db->prepare_cached($sql->rename_object); 422 422 # this SQL statment takes the new key name as the first param 423 my $rows = $query->execute($newkey->path, basename($newkey->path), $ key->path);423 my $rows = $query->execute($newkey->path, basename($newkey->path), $self->_resolve_dir_parent_id($newkey), $key->path); 424 424 425 425 # if we affected more then one row something very bad has happened. … … 497 497 my $query = $db->prepare_cached($sql->rename_object); 498 498 # this SQL statment takes the new key name as the first param 499 my $rows = $query->execute($key1->path . ".swap", basename($key1->path) . ".swap", $key1->path); 499 # XXX currently using a bogus dir_id -- this may cause a problem 500 # someday but it's unlikley as it's contained entirely in the 501 # transaction 502 my $rows = $query->execute($key1->path . ".swap", basename($key1->path) . ".swap", 1, $key1->path); 500 503 501 504 # if we affected more then one row something very bad has happened. … … 510 513 my $query = $db->prepare_cached($sql->rename_object); 511 514 # this SQL statment takes the new key name as the first param 512 my $rows = $query->execute($key1->path, basename($key1->path), $ key2->path);515 my $rows = $query->execute($key1->path, basename($key1->path), $self->_resolve_dir_parent_id($key1), $key2->path); 513 516 514 517 # if we affected more then one row something very bad has happened. … … 523 526 my $query = $db->prepare_cached($sql->rename_object); 524 527 # this SQL statment takes the new key name as the first param 525 my $rows = $query->execute($key2->path, basename($key2->path), $ key1->path . ".swap");528 my $rows = $query->execute($key2->path, basename($key2->path), $self->_resolve_dir_parent_id($key2), $key1->path . ".swap"); 526 529 527 530 # if we affected more then one row something very bad has happened. -
branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r23755 r23760 316 316 rename_object => qq{ 317 317 UPDATE storage_object 318 SET ext_id = ?, ext_id_basename = ? 318 SET ext_id = ?, ext_id_basename = ?, dir_id = ? 319 319 WHERE ext_id = ? 320 320 }, -
branches/neb_distrib_20081210/Nebulous-Server/t/03_server_create_object.t
r23755 r23760 27 27 ); 28 28 29 use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS; 30 29 31 Test::Nebulous->setup; 30 32 … … 336 338 337 339 # test for properly row creation in the directories table 338 use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS;339 340 340 341 Test::Nebulous->setup; -
branches/neb_distrib_20081210/Nebulous-Server/t/13_server_rename_object.t
r23727 r23760 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 7;10 use Test::More tests => 14; 11 11 12 12 use lib qw( ./t ./lib ); 13 13 14 use File::Basename qw( basename ); 14 15 use Nebulous::Server; 15 16 use Test::Nebulous; … … 21 22 ); 22 23 24 use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS; 25 23 26 Test::Nebulous->setup; 24 27 25 28 { 29 my $key = "bar"; 26 30 my $uri = $neb->create_object("foo"); 27 31 28 $neb->rename_object("foo", "bar"); 32 $neb->rename_object("foo", $key); 33 34 expected_dataset_ok( 35 directory => [dir_id => 1, dirname => '/', parent_id => 1], 36 storage_object => [so_id => 1, ext_id => $key, ext_id_basename => basename($key), dir_id => 1], 37 ); 38 39 eval { 40 $neb->find_objects('^foo$'); 41 }; 42 like($@, qr/no keys found/, "old key name"); 43 44 my $keys = $neb->find_objects('^bar$'); 45 is(scalar @$keys, 1, 'number of keys found'); 46 } 47 48 Test::Nebulous->setup; 49 50 { 51 my $key = "a/bar"; 52 my $uri = $neb->create_object("foo"); 53 54 $neb->rename_object("foo", $key); 55 56 expected_dataset_ok( 57 directory => [dir_id => 1, dirname => '/', parent_id => 1], 58 directory => [dir_id => 2, dirname => 'a', parent_id => 1], 59 storage_object => [so_id => 1, ext_id => $key, ext_id_basename => basename($key), dir_id => 2], 60 ); 61 62 eval { 63 $neb->find_objects('^foo$'); 64 }; 65 like($@, qr/no keys found/, "old key name"); 66 67 my $keys = $neb->find_objects('^a/bar$'); 68 is(scalar @$keys, 1, 'number of keys found'); 69 } 70 71 Test::Nebulous->setup; 72 73 { 74 my $key = "bar"; 75 my $uri = $neb->create_object("a/foo"); 76 77 $neb->rename_object("a/foo", $key); 78 79 expected_dataset_ok( 80 directory => [dir_id => 1, dirname => '/', parent_id => 1], 81 directory => [dir_id => 2, dirname => 'a', parent_id => 1], 82 storage_object => [so_id => 1, ext_id => $key, ext_id_basename => basename($key), dir_id => 1], 83 ); 29 84 30 85 eval {
Note:
See TracChangeset
for help on using the changeset viewer.
