Skip to content

Commit

Permalink
Revert "fix: Remove batch uploads when deleting a user."
Browse files Browse the repository at this point in the history
This reverts commit 8d6dfc7.
  • Loading branch information
tommie committed Jan 8, 2025
1 parent 180d862 commit 581b620
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 38 deletions.
12 changes: 0 additions & 12 deletions syncstorage-mysql/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,6 @@ pub fn delete(db: &MysqlDb, params: params::DeleteBatch) -> DbResult<()> {
Ok(())
}

/// Cleans up uncommitted batch data for the user
pub fn delete_for_user(db: &MysqlDb, user_id: UserIdentifier) -> DbResult<()> {
let user_id = user_id.legacy_id as i64;
diesel::delete(batch_uploads::table)
.filter(batch_uploads::user_id.eq(&user_id))
.execute(&mut *db.conn.write().unwrap())?;
diesel::delete(batch_upload_items::table)
.filter(batch_upload_items::user_id.eq(&user_id))
.execute(&mut *db.conn.write().unwrap())?;
Ok(())
}

/// Commits a batch to the bsos table, deleting the batch when succesful
pub fn commit(db: &MysqlDb, params: params::CommitBatch) -> DbResult<results::CommitBatch> {
let batch_id = decode_id(&params.batch.id)?;
Expand Down
7 changes: 3 additions & 4 deletions syncstorage-mysql/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,15 @@ impl MysqlDb {
}

fn delete_storage_sync(&self, user_id: UserIdentifier) -> DbResult<()> {
let user_id_i64 = user_id.legacy_id as i64;
let user_id = user_id.legacy_id as i64;
// Delete user data.
delete(bso::table)
.filter(bso::user_id.eq(user_id_i64))
.filter(bso::user_id.eq(user_id))
.execute(&mut *self.conn.write().unwrap())?;
// Delete user collections.
delete(user_collections::table)
.filter(user_collections::user_id.eq(user_id_i64))
.filter(user_collections::user_id.eq(user_id))
.execute(&mut *self.conn.write().unwrap())?;
batch::delete_for_user(self, user_id)?;
Ok(())
}

Expand Down
19 changes: 0 additions & 19 deletions syncstorage-spanner/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,6 @@ pub async fn delete_async(db: &SpannerDb, params: params::DeleteBatch) -> DbResu
Ok(())
}

pub async fn delete_for_user_async(db: &SpannerDb, user_id: UserIdentifier) -> DbResult<()> {
let (sqlparams, sqlparam_types) = params! {
"fxa_uid" => user_id.fxa_uid.clone(),
"fxa_kid" => user_id.fxa_kid.clone(),
};
// Also deletes child batch_bsos rows (INTERLEAVE IN PARENT batches ON
// DELETE CASCADE)
db.sql(
"DELETE FROM batches
WHERE fxa_uid = @fxa_uid
AND fxa_kid = @fxa_kid",
)?
.params(sqlparams)
.param_types(sqlparam_types)
.execute_dml_async(&db.conn)
.await?;
Ok(())
}

pub async fn commit_async(
db: &SpannerDb,
params: params::CommitBatch,
Expand Down
5 changes: 2 additions & 3 deletions syncstorage-spanner/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,8 @@ impl SpannerDb {
// Also deletes child bsos/batch rows (INTERLEAVE IN PARENT
// user_collections ON DELETE CASCADE)
let (sqlparams, sqlparam_types) = params! {
"fxa_uid" => user_id.fxa_uid.clone(),
"fxa_kid" => user_id.fxa_kid.clone()
"fxa_uid" => user_id.fxa_uid,
"fxa_kid" => user_id.fxa_kid
};
self.sql(
"DELETE FROM user_collections
Expand All @@ -1023,7 +1023,6 @@ impl SpannerDb {
.param_types(sqlparam_types)
.execute_dml_async(&self.conn)
.await?;
batch::delete_for_user_async(self, user_id).await?;
Ok(())
}

Expand Down

0 comments on commit 581b620

Please sign in to comment.