diff --git a/crates/in-core/src/store/mod.rs b/crates/in-core/src/store/mod.rs
index b9500bf..860a4d2 100644
--- a/crates/in-core/src/store/mod.rs
+++ b/crates/in-core/src/store/mod.rs
@@ -23,10 +23,10 @@ pub mod sniff;
#[cfg(feature = "server")]
pub mod turso_store;
-#[cfg(feature = "server")]
-pub use turso_store::{TursoStore, hash_share_token};
#[cfg(feature = "server")]
pub use reconcile::{ReconcileOptions, reconcile};
+#[cfg(feature = "server")]
+pub use turso_store::{TursoStore, hash_share_token};
/// What the store can fail with. A caller that needs to distinguish "no such
/// row" from "someone else's row" gets [`StoreError::NotFound`] for the
@@ -131,9 +131,10 @@ pub struct File {
/// What the server decided the bytes are, never what the upload claimed.
pub mime: String,
pub size_bytes: u64,
- /// How many times the bytes went to a reader: the download route and the
- /// public-link bytes bump it through [`Store::record_download`], and
- /// nothing internal — thumbnails, sniffing, the boot sweep — ever does.
+ /// How many times the bytes went to a downloader: the download route's
+ /// `?dl=1` serves and the public-link bytes bump it through
+ /// [`Store::record_download`], and nothing internal — previews,
+ /// thumbnails, sniffing, the boot sweep — ever does.
pub download_count: u64,
pub thumb_state: ThumbState,
pub created_at: OffsetDateTime,
@@ -410,11 +411,7 @@ pub trait Store: 'static + Send + Sync {
/// One directory's live contents: the folders and files whose parent is
/// `parent_id` (`None` is the root) and whose trash timestamp is empty.
- async fn list_children(
- &self,
- owner_id: &str,
- parent_id: Option<&str>,
- ) -> Result
;
+ async fn list_children(&self, owner_id: &str, parent_id: Option<&str>) -> Result;
/// Stores small bytes straight through: sanitises the name, checks the
/// quota, sniffs the mime (never trusting the uploader), writes the
@@ -454,11 +451,11 @@ pub trait Store: 'static + Send + Sync {
/// when no thumbnail was made, or its file went missing.
async fn thumb_bytes(&self, id: &str) -> Result>>;
- /// Counts one user-facing serve of a file's bytes. Byte routes call this
- /// once per download they complete — not per range chunk, not per
- /// thumbnail, never from internal reads (sniffing, the boot sweep).
- /// [`Store::file_bytes`] is a pure read and does not call it. Unknown
- /// ids are [`StoreError::NotFound`].
+ /// Counts one user-facing download of a file's bytes. Byte routes call
+ /// this once per download they complete — on `?dl=1` serves, not per
+ /// range chunk, never for inline previews, thumbnails, or internal reads
+ /// (sniffing, the boot sweep). [`Store::file_bytes`] is a pure read and
+ /// does not call it. Unknown ids are [`StoreError::NotFound`].
async fn record_download(&self, id: &str) -> Result<()>;
// -- trash -------------------------------------------------------------
@@ -581,8 +578,7 @@ pub trait Store: 'static + Send + Sync {
/// it — may. A grant on a folder covers everything under it. Nobody else
/// may — and the answer never says which of "no such target" and "not
/// shared" it was.
- async fn can_see(&self, kind: ShareKind, target_id: &str, user_id: &str)
- -> Result;
+ async fn can_see(&self, kind: ShareKind, target_id: &str, user_id: &str) -> Result;
/// Whether `user_id` may download the target: its owner always may, and
/// anyone may who sees it through a grant whose `can_download` is set —
@@ -590,12 +586,7 @@ pub trait Store: 'static + Send + Sync {
/// permissive grant on the chain wins: a download grant above the target
/// opens the bytes even under a view-only grant on the target itself.
/// A view-only grant alone opens the page but not the bytes.
- async fn can_download(
- &self,
- kind: ShareKind,
- target_id: &str,
- user_id: &str,
- ) -> Result;
+ async fn can_download(&self, kind: ShareKind, target_id: &str, user_id: &str) -> Result;
// -- chunked uploads ---------------------------------------------------
@@ -619,12 +610,7 @@ pub trait Store: 'static + Send + Sync {
/// re-sending an index replaces its bytes rather than counting them
/// twice. Anything past the declared total, or on a session that is not
/// active and unexpired, is refused.
- async fn record_chunk(
- &self,
- id: &str,
- index: u64,
- bytes: &[u8],
- ) -> Result;
+ async fn record_chunk(&self, id: &str, index: u64, bytes: &[u8]) -> Result;
/// Assembles a session's chunks in order, rechecks the quota, sniffs the
/// mime (never trusting anything the uploader said), writes the file,
@@ -658,10 +644,5 @@ pub trait Store: 'static + Send + Sync {
/// Owner-scoped substring search over live file and folder names, files
/// and folders in their own lists. At most `limit` of each.
- async fn search(
- &self,
- owner_id: &str,
- query: &str,
- limit: u32,
- ) -> Result;
+ async fn search(&self, owner_id: &str, query: &str, limit: u32) -> Result;
}
diff --git a/crates/in-web/src/drive.rs b/crates/in-web/src/drive.rs
index f42e493..07b346c 100644
--- a/crates/in-web/src/drive.rs
+++ b/crates/in-web/src/drive.rs
@@ -63,6 +63,7 @@ struct DriveQuery {
sort: Option,
share: Option,
kind: Option,
+ r#move: Option,
}
/// The folder the query names, if it names one this account may open: owned,
@@ -137,6 +138,124 @@ async fn folder_tree(store: &dyn Store, user_id: &str) -> Vec<(String, String)>
out
}
+/// The move picker's modal: `?move=kind:id` renders the drive root and every
+/// live folder as one clickable row each over the page — the file-manager
+/// idiom, replacing the select that used to sit inside the Options menu.
+/// A folder's own subtree is left out: a move into itself or a descendant is
+/// the store's refusal, and a row that can never be picked is noise. Sibling
+/// names cannot collide (the store postfixes them), so the display path
+/// identifies a subtree exactly. A pair naming nothing owned and live opens
+/// nothing.
+async fn move_modal(
+ cx: &Cx,
+ kind_raw: &str,
+ target_id: &str,
+ close_href: &str,
+ destinations: &[(String, String)],
+) -> Result> {
+ let user = match require_user(cx).await {
+ Ok(user) => user,
+ Err(_) => return Ok(None),
+ };
+ let language = lang(cx).await;
+ let store = app(cx).store.clone();
+ // The owned, live target, the endpoint its rows post to, and — for a
+ // folder — the path prefix that marks its own subtree off the list.
+ let (name, file, action, field, own_path): (
+ String,
+ Option,
+ &str,
+ &str,
+ Option,
+ ) = match kind_raw {
+ "file" => {
+ let Some(file) = store.file(target_id).await? else {
+ return Ok(None);
+ };
+ if file.owner_id != user.id || file.deleted_at.is_some() {
+ return Ok(None);
+ }
+ (
+ file.name.clone(),
+ Some(file),
+ "/api/file/move",
+ "folder_id",
+ None,
+ )
+ }
+ "folder" => {
+ let Some(folder) = store.folder(target_id).await? else {
+ return Ok(None);
+ };
+ if folder.owner_id != user.id || folder.deleted_at.is_some() {
+ return Ok(None);
+ }
+ let own = destinations
+ .iter()
+ .find(|dest| dest.0 == target_id)
+ .map(|dest| dest.1.clone());
+ (
+ folder.name.clone(),
+ None,
+ "/api/folder/move",
+ "parent_id",
+ own,
+ )
+ }
+ _ => return Ok(None),
+ };
+ let subtree = own_path.map(|path| format!("{path} / "));
+ let rows: Vec<&(String, String)> = destinations
+ .iter()
+ .filter(|dest| match &subtree {
+ Some(prefix) => {
+ !dest.1.starts_with(prefix.as_str()) && dest.1 != prefix.trim_end_matches(" / ")
+ }
+ None => true,
+ })
+ .collect();
+ Ok(Some(view! {
+ cx =>
+
+
+
+
+ if kind_raw == "folder" {
+ "▤"
+ }
+ if let Some(file) = file.as_ref() {
+ (crate::files::entry_chip(cx, file).await?)
+ }
+ (format!("{} “{}”", t(language, Key::Move), name.clone()))
+
+
+
(t(language, Key::Close))
+
+
+
+ for dest in rows {
+
+ }
+
+
+
+ }?))
+}
+
fn human_size(bytes: u64) -> String {
const UNITS: [&str; 5] = ["B", "KB", "MB", "GB", "TB"];
let mut size = bytes as f64;
@@ -366,7 +485,13 @@ async fn drive(cx: &Cx) -> Result {
KindFilter::Files => found.folders.clear(),
}
}
- let destinations = folder_tree(store.as_ref(), &user.id).await;
+ // The destination tree only pays when the move picker is open.
+ let move_pair = params.as_ref().and_then(|query| query.r#move.as_deref());
+ let destinations = if move_pair.is_some() {
+ folder_tree(store.as_ref(), &user.id).await
+ } else {
+ Vec::new()
+ };
let refusal = page_refusal(cx);
// Which folder row (if any) renders as its rename form: iz's `?edit=`
// idiom — a server-side row swap, no client state to hold.
@@ -422,6 +547,14 @@ async fn drive(cx: &Cx) -> Result {
}
None => None,
};
+ // The move picker: `?move=kind:id` renders the destination modal over
+ // the page — one shot, unlike the share dialog: a posted move comes back
+ // through `back_to`, which strips the pair, so the modal closes on both
+ // success and refusal (the refusal then wears the page banner).
+ let move_dialog = match move_pair.and_then(|pair| pair.split_once(':')) {
+ Some((move_kind, id)) => move_modal(cx, move_kind, id, &here, &destinations).await?,
+ None => None,
+ };
// The copy-once banner belongs to the modal when it is open.
let created_panel = if share_pair.is_some() {
None
@@ -593,20 +726,8 @@ async fn drive(cx: &Cx) -> Result {
href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))
-
+
+ // The `download` attribute keeps the
+ // soft-nav handler off the click, so the
+ // bytes land as a file, not a page swap.
+
+