Changeset 13071
- Timestamp:
- Apr 27, 2007, 2:44:58 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
-
Nebulous-Server/Changes (modified) (1 diff)
-
Nebulous-Server/MANIFEST (modified) (1 diff)
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (2 diffs)
-
Nebulous-Server/lib/Nebulous/Server/SQL.pm (modified) (2 diffs)
-
Nebulous-Server/t/13_server_rename_object.t (added)
-
Nebulous/Changes (modified) (1 diff)
-
Nebulous/MANIFEST (modified) (1 diff)
-
Nebulous/lib/Nebulous/Server.pm (modified) (2 diffs)
-
Nebulous/lib/Nebulous/Server/SQL.pm (modified) (2 diffs)
-
Nebulous/t/13_server_rename_object.t (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r13069 r13071 2 2 3 3 0.05 4 - add Nebulous::Server->rename_object() 4 5 - add neb-rm 5 6 - add neb-cp -
trunk/Nebulous-Server/MANIFEST
r13069 r13071 88 88 t/11_server_is_valid_class_id.t 89 89 t/12_server_find_objects.t 90 t/13_server_rename_object.t 90 91 t/50_client_new.t 91 92 t/51_client_create.t -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r13047 r13071 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.2 5 2007-04-26 23:45:03jhoblitt Exp $3 # $Id: Server.pm,v 1.26 2007-04-28 00:44:38 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 236 236 } 237 237 238 sub rename_object { 239 my $self = shift; 240 241 my ( $key, $newkey ) = validate_pos( @_, 242 { 243 type => SCALAR, 244 }, 245 { 246 type => SCALAR, 247 }, 248 ); 249 250 my $log = $self->log; 251 my $sql = $self->sql; 252 my $db =$self->db; 253 254 $log->debug( "entered - @_" ); 255 256 eval { 257 # rename storage_object 258 my $query = $db->prepare_cached($sql->rename_object); 259 # this SQL statment takes the new key name as the first param 260 my $rows = $query->execute($newkey, $key); 261 262 # if we affected more then one row something very bad has happened. 263 unless ( $rows == 1 ) { 264 $log->logdie( "affected row count is $rows instead of 1" ); 265 } 266 }; 267 if ($@) { 268 $db->rollback; 269 $log->logdie( "database error: $@" ); 270 } 271 272 eval { 273 $db->commit; 274 }; 275 if ( $@ ) { 276 $db->rollback; 277 $log->logdie( "database error: $@" ); 278 } 279 280 $log->debug( "leaving" ); 281 282 return $newkey; 283 } 284 238 285 sub replicate_object { 239 286 my $self = shift; -
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r13047 r13071 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1.2 7 2007-04-26 23:45:03jhoblitt Exp $3 # $Id: SQL.pm,v 1.28 2007-04-28 00:44:38 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 153 153 FROM storage_object 154 154 WHERE ext_id REGEXP ? 155 }, 156 rename_object => qq{ 157 UPDATE storage_object 158 SET ext_id = ? 159 WHERE ext_id = ? 155 160 }, 156 161 ); -
trunk/Nebulous/Changes
r13069 r13071 2 2 3 3 0.05 4 - add Nebulous::Server->rename_object() 4 5 - add neb-rm 5 6 - add neb-cp -
trunk/Nebulous/MANIFEST
r13069 r13071 88 88 t/11_server_is_valid_class_id.t 89 89 t/12_server_find_objects.t 90 t/13_server_rename_object.t 90 91 t/50_client_new.t 91 92 t/51_client_create.t -
trunk/Nebulous/lib/Nebulous/Server.pm
r13047 r13071 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.2 5 2007-04-26 23:45:03jhoblitt Exp $3 # $Id: Server.pm,v 1.26 2007-04-28 00:44:38 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 236 236 } 237 237 238 sub rename_object { 239 my $self = shift; 240 241 my ( $key, $newkey ) = validate_pos( @_, 242 { 243 type => SCALAR, 244 }, 245 { 246 type => SCALAR, 247 }, 248 ); 249 250 my $log = $self->log; 251 my $sql = $self->sql; 252 my $db =$self->db; 253 254 $log->debug( "entered - @_" ); 255 256 eval { 257 # rename storage_object 258 my $query = $db->prepare_cached($sql->rename_object); 259 # this SQL statment takes the new key name as the first param 260 my $rows = $query->execute($newkey, $key); 261 262 # if we affected more then one row something very bad has happened. 263 unless ( $rows == 1 ) { 264 $log->logdie( "affected row count is $rows instead of 1" ); 265 } 266 }; 267 if ($@) { 268 $db->rollback; 269 $log->logdie( "database error: $@" ); 270 } 271 272 eval { 273 $db->commit; 274 }; 275 if ( $@ ) { 276 $db->rollback; 277 $log->logdie( "database error: $@" ); 278 } 279 280 $log->debug( "leaving" ); 281 282 return $newkey; 283 } 284 238 285 sub replicate_object { 239 286 my $self = shift; -
trunk/Nebulous/lib/Nebulous/Server/SQL.pm
r13047 r13071 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1.2 7 2007-04-26 23:45:03jhoblitt Exp $3 # $Id: SQL.pm,v 1.28 2007-04-28 00:44:38 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 153 153 FROM storage_object 154 154 WHERE ext_id REGEXP ? 155 }, 156 rename_object => qq{ 157 UPDATE storage_object 158 SET ext_id = ? 159 WHERE ext_id = ? 155 160 }, 156 161 );
Note:
See TracChangeset
for help on using the changeset viewer.
