WIP
This commit is contained in:
parent
29a4baf346
commit
585ac3e1be
2 changed files with 47 additions and 36 deletions
|
@ -9,6 +9,7 @@ mod signup;
|
||||||
mod tests;
|
mod tests;
|
||||||
mod user;
|
mod user;
|
||||||
mod worktree;
|
mod worktree;
|
||||||
|
mod worktree_entry;
|
||||||
|
|
||||||
use crate::{Error, Result};
|
use crate::{Error, Result};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
@ -1599,44 +1600,28 @@ impl Database {
|
||||||
connection_id: ConnectionId,
|
connection_id: ConnectionId,
|
||||||
) -> Result<RoomGuard<Vec<ConnectionId>>> {
|
) -> Result<RoomGuard<Vec<ConnectionId>>> {
|
||||||
self.transact(|tx| async move {
|
self.transact(|tx| async move {
|
||||||
todo!()
|
let project_id = ProjectId::from_proto(update.project_id);
|
||||||
// let project_id = ProjectId::from_proto(update.project_id);
|
let worktree_id = WorktreeId::from_proto(update.worktree_id);
|
||||||
// let worktree_id = WorktreeId::from_proto(update.worktree_id);
|
|
||||||
|
|
||||||
// // Ensure the update comes from the host.
|
// Ensure the update comes from the host.
|
||||||
// let room_id: RoomId = sqlx::query_scalar(
|
let project = project::Entity::find_by_id(project_id)
|
||||||
// "
|
.filter(project::Column::HostConnectionId.eq(connection_id.0))
|
||||||
// SELECT room_id
|
.one(&tx)
|
||||||
// FROM projects
|
.await?
|
||||||
// WHERE id = $1 AND host_connection_id = $2
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
// ",
|
|
||||||
// )
|
|
||||||
// .bind(project_id)
|
|
||||||
// .bind(connection_id.0 as i32)
|
|
||||||
// .fetch_one(&mut tx)
|
|
||||||
// .await?;
|
|
||||||
|
|
||||||
// // Update metadata.
|
// Update metadata.
|
||||||
// sqlx::query(
|
worktree::Entity::update(worktree::ActiveModel {
|
||||||
// "
|
id: ActiveValue::set(worktree_id),
|
||||||
// UPDATE worktrees
|
project_id: ActiveValue::set(project_id),
|
||||||
// SET
|
root_name: ActiveValue::set(update.root_name.clone()),
|
||||||
// root_name = $1,
|
scan_id: ActiveValue::set(update.scan_id as u32),
|
||||||
// scan_id = $2,
|
is_complete: ActiveValue::set(update.is_last_update),
|
||||||
// is_complete = $3,
|
abs_path: ActiveValue::set(update.abs_path.clone()),
|
||||||
// abs_path = $4
|
..Default::default()
|
||||||
// WHERE project_id = $5 AND id = $6
|
})
|
||||||
// RETURNING 1
|
.exec(&tx)
|
||||||
// ",
|
.await?;
|
||||||
// )
|
|
||||||
// .bind(&update.root_name)
|
|
||||||
// .bind(update.scan_id as i64)
|
|
||||||
// .bind(update.is_last_update)
|
|
||||||
// .bind(&update.abs_path)
|
|
||||||
// .bind(project_id)
|
|
||||||
// .bind(worktree_id)
|
|
||||||
// .fetch_one(&mut tx)
|
|
||||||
// .await?;
|
|
||||||
|
|
||||||
// if !update.updated_entries.is_empty() {
|
// if !update.updated_entries.is_empty() {
|
||||||
// let mut params =
|
// let mut params =
|
||||||
|
@ -1706,6 +1691,8 @@ impl Database {
|
||||||
// let connection_ids = self.get_guest_connection_ids(project_id, &mut tx).await?;
|
// let connection_ids = self.get_guest_connection_ids(project_id, &mut tx).await?;
|
||||||
// self.commit_room_transaction(room_id, tx, connection_ids)
|
// self.commit_room_transaction(room_id, tx, connection_ids)
|
||||||
// .await
|
// .await
|
||||||
|
|
||||||
|
todo!()
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -2456,6 +2443,7 @@ id_type!(ReplicaId);
|
||||||
id_type!(SignupId);
|
id_type!(SignupId);
|
||||||
id_type!(UserId);
|
id_type!(UserId);
|
||||||
id_type!(WorktreeId);
|
id_type!(WorktreeId);
|
||||||
|
id_type!(WorktreeEntryId);
|
||||||
|
|
||||||
pub struct LeftRoom {
|
pub struct LeftRoom {
|
||||||
pub room: proto::Room,
|
pub room: proto::Room,
|
||||||
|
|
23
crates/collab/src/db/worktree_entry.rs
Normal file
23
crates/collab/src/db/worktree_entry.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use super::{ProjectId, WorktreeEntryId, WorktreeId};
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "worktree_entries")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
project_id: ProjectId,
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
worktree_id: WorktreeId,
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
id: WorktreeEntryId,
|
||||||
|
is_dir: bool,
|
||||||
|
path: String,
|
||||||
|
inode: u64,
|
||||||
|
mtime_seconds: u64,
|
||||||
|
mtime_nanos: u32,
|
||||||
|
is_symlink: bool,
|
||||||
|
is_ignored: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {}
|
Loading…
Add table
Add a link
Reference in a new issue