File tree 2 files changed +13
-3
lines changed
components/data_proxy/src
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use super::grpc_query_handler::GrpcQueryHandler;
2
2
use crate :: auth:: auth:: AuthHandler ;
3
3
use crate :: caching:: grpc_query_handler:: sort_objects;
4
4
use crate :: data_backends:: storage_backend:: StorageBackend ;
5
- use crate :: database:: persistence:: delete_parts_by_upload_id;
5
+ use crate :: database:: persistence:: { delete_parts_by_object_id , delete_parts_by_upload_id} ;
6
6
use crate :: replication:: replication_handler:: ReplicationMessage ;
7
7
use crate :: s3_frontend:: data_handler:: DataHandler ;
8
8
use crate :: structs:: {
@@ -813,6 +813,7 @@ impl Cache {
813
813
let transaction = client. transaction ( ) . await ?;
814
814
let transaction_client = transaction. client ( ) ;
815
815
816
+ delete_parts_by_object_id ( transaction_client, & id) . await ?;
816
817
ObjectLocation :: delete ( & id, transaction_client) . await ?;
817
818
Object :: delete ( & id, transaction_client) . await ?;
818
819
@@ -835,6 +836,9 @@ impl Cache {
835
836
return Ok ( ( ) ) ;
836
837
} ;
837
838
839
+ self . multi_parts
840
+ . retain ( |_, v| v. first ( ) . map_or ( true , |e| e. object_id != id) ) ;
841
+
838
842
let object = old. 1 . 0 . read ( ) . await ;
839
843
for p in self
840
844
. get_name_trees ( & TypedId :: from ( object. deref ( ) ) , object. name . clone ( ) , None )
Original file line number Diff line number Diff line change @@ -218,8 +218,14 @@ pub async fn _get_parts_by_upload_id(
218
218
pub async fn delete_parts_by_upload_id ( client : & Client , upload_id : String ) -> Result < ( ) > {
219
219
let query = "DELETE FROM multiparts WHERE data->>'upload_id' = $1;" ;
220
220
let prepared = client. prepare ( query) . await ?;
221
- let deleted = client. execute ( & prepared, & [ & upload_id] ) . await ?;
222
- debug ! ( "Deleted {} parts for {}" , deleted, upload_id) ;
221
+ client. execute ( & prepared, & [ & upload_id] ) . await ?;
222
+ Ok ( ( ) )
223
+ }
224
+
225
+ pub async fn delete_parts_by_object_id ( client : & Client , object_id : & DieselUlid ) -> Result < ( ) > {
226
+ let query = "DELETE FROM multiparts WHERE data->>'object_id' = $1;" ;
227
+ let prepared = client. prepare ( query) . await ?;
228
+ client. execute ( & prepared, & [ & object_id. to_string ( ) ] ) . await ?;
223
229
Ok ( ( ) )
224
230
}
225
231
You can’t perform that action at this time.
0 commit comments