File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ impl Transaction {
100
100
}
101
101
102
102
pub fn rollback ( & self ) { self . rollback . set ( true ) ; }
103
+ pub fn commit ( & self ) { self . rollback . set ( false ) ; }
103
104
}
104
105
105
106
impl Middleware for TransactionMiddleware {
@@ -141,6 +142,8 @@ pub trait RequestTransaction<'a> {
141
142
142
143
/// Do not commit this request's transaction, even if it finishes ok.
143
144
fn rollback ( self ) ;
145
+ /// Flag this transaction to be committed (this is the default)
146
+ fn commit ( self ) ;
144
147
}
145
148
146
149
impl < ' a > RequestTransaction < ' a > for & ' a Request + ' a {
@@ -161,6 +164,12 @@ impl<'a> RequestTransaction<'a> for &'a Request + 'a {
161
164
. expect ( "Transaction not present in request" )
162
165
. rollback ( )
163
166
}
167
+
168
+ fn commit ( self ) {
169
+ self . extensions ( ) . find :: < Transaction > ( )
170
+ . expect ( "Transaction not present in request" )
171
+ . commit ( )
172
+ }
164
173
}
165
174
166
175
pub trait Connection {
Original file line number Diff line number Diff line change @@ -419,6 +419,7 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {
419
419
420
420
pub fn new ( req : & mut Request ) -> CargoResult < Response > {
421
421
let app = req. app ( ) . clone ( ) ;
422
+ req. rollback ( ) ;
422
423
423
424
let ( new_crate, user) = try!( parse_new_headers ( req) ) ;
424
425
let name = new_crate. name . as_slice ( ) ;
@@ -509,6 +510,7 @@ pub fn new(req: &mut Request) -> CargoResult<Response> {
509
510
510
511
// Now that we've come this far, we're committed!
511
512
bomb. path = None ;
513
+ req. commit ( ) ;
512
514
513
515
#[ deriving( Encodable ) ]
514
516
struct R { krate : EncodableCrate }
You can’t perform that action at this time.
0 commit comments