IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23760


Ignore:
Timestamp:
Apr 8, 2009, 4:51:15 PM (17 years ago)
Author:
jhoblitt
Message:

fixup the directory structure on object rename

Location:
branches/neb_distrib_20081210/Nebulous-Server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server.pm

    r23755 r23760  
    421421            my $query = $db->prepare_cached($sql->rename_object);
    422422            # 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);
    424424
    425425            # if we affected more then one row something very bad has happened.
     
    497497              my $query = $db->prepare_cached($sql->rename_object);
    498498              # 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);
    500503
    501504              # if we affected more then one row something very bad has happened.
     
    510513              my $query = $db->prepare_cached($sql->rename_object);
    511514              # 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);
    513516
    514517              # if we affected more then one row something very bad has happened.
     
    523526              my $query = $db->prepare_cached($sql->rename_object);
    524527              # 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");
    526529
    527530              # 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  
    316316    rename_object => qq{
    317317        UPDATE storage_object
    318         SET ext_id = ?, ext_id_basename = ?
     318        SET ext_id = ?, ext_id_basename = ?, dir_id = ?
    319319        WHERE ext_id = ?
    320320    },
  • branches/neb_distrib_20081210/Nebulous-Server/t/03_server_create_object.t

    r23755 r23760  
    2727);
    2828
     29use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS;
     30
    2931Test::Nebulous->setup;
    3032
     
    336338
    337339# test for properly row creation in the directories table
    338 use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS;
    339340
    340341Test::Nebulous->setup;
  • branches/neb_distrib_20081210/Nebulous-Server/t/13_server_rename_object.t

    r23727 r23760  
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 7;
     10use Test::More tests => 14;
    1111
    1212use lib qw( ./t ./lib );
    1313
     14use File::Basename qw( basename );
    1415use Nebulous::Server;
    1516use Test::Nebulous;
     
    2122);
    2223
     24use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS;
     25
    2326Test::Nebulous->setup;
    2427
    2528{
     29    my $key = "bar";
    2630    my $uri = $neb->create_object("foo");
    2731
    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
     48Test::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
     71Test::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    );
    2984
    3085    eval {
Note: See TracChangeset for help on using the changeset viewer.