--- trunk/lib/Frey/CouchAPI.pm 2009/04/23 22:18:46 1057 +++ trunk/lib/Frey/CouchAPI.pm 2009/04/24 15:32:04 1059 @@ -118,14 +118,18 @@ $status = 501; } - } elsif ( $url =~ m{($regex_dbs)/$} ) { - =head2 Database L except compaction =cut + } elsif ( + $url =~ m{($regex_dbs)/$} + # DELETE doesn't have trailing slash + || $method eq 'DELETE' && $url =~ m{($regex_dbs)$} + ) { + my $database = $1; my $dir = "$path/$database"; @@ -157,6 +161,8 @@ } } + warn "## database $database $status ",dump( $json ); + } elsif ( $url =~ m{($regex_dbs)/([^?]+)\??(.+)?$} ) { my ($database,$id,$args) = ($1,$2,$3); @@ -260,10 +266,13 @@ } elsif ( $method eq 'PUT' ) { - warn "## ",dump( $tx->req ); # if $debug; + warn "## ",dump( $tx->req ) if $debug; my $data = $tx->req->content->file->slurp; + my $db_path = "$path/$database"; + make_path $db_path unless -e $db_path; + Storable::store( from_json($data), $p ); my $rev = file_rev $p; warn "store $p $rev size ", -s $p, " bytes | $data\n"; @@ -304,7 +313,10 @@ $status = 501; } - warn "WARNING: arg left from $url = ",dump( $arg ),$/ if keys %$arg; + if ( keys %$arg ) { + warn "WARNING: arg left from $url = ",dump( $arg ),$/; + $status = 501; + } }