forge
Explore
Log in

Don't you dare go Hollow

Move picker modal, Download in the Options menu, previews don't count

Browse files at this commit

5cc7c91b0c1921e4872b1e2364bb7304f9cf494cAhmet Kaan GümüşParent: 47b70b9
  • feat
    • move picker modal, Download in the Options menu, previews don't count
Show full message
feat(ui): move picker modal, Download in the Options menu, previews don't count

The Options menus' inline destination select becomes a Move item that opens
the house modal: the drive root and every live folder as one row each, a
folder's own subtree never listed. back_to and __inCloseModal strip the
one-shot move= pair, so a posted move closes the picker on success and
refusal alike. The destination tree fetch goes lazy with the select gone.

File rows gain a Download item — /file/<id>?dl=1 with the download
attribute, so the soft-nav handler leaves the click to the browser.

/file/<id> counted every byte serve, the viewer's inline loads and media
range probes included; looking is not downloading, so only ?dl=1 serves
count now (a resumed download still counts once, on its first chunk). The
public-link path already counted downloads only. Regression test:
previews_do_not_count_as_downloads.
crates/in-core/src/store/mod.rsmodified+16 -35
@@ -23,10 +23,10 @@ pub mod sniff;
23 #[cfg(feature = "server")]23 #[cfg(feature = "server")]
24 pub mod turso_store;24 pub mod turso_store;
25 25
26-#[cfg(feature = "server")]
27-pub use turso_store::{TursoStore, hash_share_token};
28 #[cfg(feature = "server")]26 #[cfg(feature = "server")]
29 pub use reconcile::{ReconcileOptions, reconcile};27 pub use reconcile::{ReconcileOptions, reconcile};
28+#[cfg(feature = "server")]
29+pub use turso_store::{TursoStore, hash_share_token};
30 30
31 /// What the store can fail with. A caller that needs to distinguish "no such31 /// What the store can fail with. A caller that needs to distinguish "no such
32 /// row" from "someone else's row" gets [`StoreError::NotFound`] for the32 /// row" from "someone else's row" gets [`StoreError::NotFound`] for the
@@ -131,9 +131,10 @@ pub struct File {
131 /// What the server decided the bytes are, never what the upload claimed.131 /// What the server decided the bytes are, never what the upload claimed.
132 pub mime: String,132 pub mime: String,
133 pub size_bytes: u64,133 pub size_bytes: u64,
134- /// How many times the bytes went to a reader: the download route and the134+ /// How many times the bytes went to a downloader: the download route's
135- /// public-link bytes bump it through [`Store::record_download`], and135+ /// `?dl=1` serves and the public-link bytes bump it through
136- /// nothing internal — thumbnails, sniffing, the boot sweep — ever does.136+ /// [`Store::record_download`], and nothing internal — previews,
137+ /// thumbnails, sniffing, the boot sweep — ever does.
137 pub download_count: u64,138 pub download_count: u64,
138 pub thumb_state: ThumbState,139 pub thumb_state: ThumbState,
139 pub created_at: OffsetDateTime,140 pub created_at: OffsetDateTime,
@@ -410,11 +411,7 @@ pub trait Store: 'static + Send + Sync {
410 411
411 /// One directory's live contents: the folders and files whose parent is412 /// One directory's live contents: the folders and files whose parent is
412 /// `parent_id` (`None` is the root) and whose trash timestamp is empty.413 /// `parent_id` (`None` is the root) and whose trash timestamp is empty.
413- async fn list_children(414+ async fn list_children(&self, owner_id: &str, parent_id: Option<&str>) -> Result<Listing>;
414- &self,
415- owner_id: &str,
416- parent_id: Option<&str>,
417- ) -> Result<Listing>;
418 415
419 /// Stores small bytes straight through: sanitises the name, checks the416 /// Stores small bytes straight through: sanitises the name, checks the
420 /// quota, sniffs the mime (never trusting the uploader), writes the417 /// quota, sniffs the mime (never trusting the uploader), writes the
@@ -454,11 +451,11 @@ pub trait Store: 'static + Send + Sync {
454 /// when no thumbnail was made, or its file went missing.451 /// when no thumbnail was made, or its file went missing.
455 async fn thumb_bytes(&self, id: &str) -> Result<Option<Vec<u8>>>;452 async fn thumb_bytes(&self, id: &str) -> Result<Option<Vec<u8>>>;
456 453
457- /// Counts one user-facing serve of a file's bytes. Byte routes call this454+ /// Counts one user-facing download of a file's bytes. Byte routes call
458- /// once per download they complete — not per range chunk, not per455+ /// this once per download they complete — on `?dl=1` serves, not per
459- /// thumbnail, never from internal reads (sniffing, the boot sweep).456+ /// range chunk, never for inline previews, thumbnails, or internal reads
460- /// [`Store::file_bytes`] is a pure read and does not call it. Unknown457+ /// (sniffing, the boot sweep). [`Store::file_bytes`] is a pure read and
461- /// ids are [`StoreError::NotFound`].458+ /// does not call it. Unknown ids are [`StoreError::NotFound`].
462 async fn record_download(&self, id: &str) -> Result<()>;459 async fn record_download(&self, id: &str) -> Result<()>;
463 460
464 // -- trash -------------------------------------------------------------461 // -- trash -------------------------------------------------------------
@@ -581,8 +578,7 @@ pub trait Store: 'static + Send + Sync {
581 /// it — may. A grant on a folder covers everything under it. Nobody else578 /// it — may. A grant on a folder covers everything under it. Nobody else
582 /// may — and the answer never says which of "no such target" and "not579 /// may — and the answer never says which of "no such target" and "not
583 /// shared" it was.580 /// shared" it was.
584- async fn can_see(&self, kind: ShareKind, target_id: &str, user_id: &str)581+ async fn can_see(&self, kind: ShareKind, target_id: &str, user_id: &str) -> Result<bool>;
585- -> Result<bool>;
586 582
587 /// Whether `user_id` may download the target: its owner always may, and583 /// Whether `user_id` may download the target: its owner always may, and
588 /// anyone may who sees it through a grant whose `can_download` is set —584 /// anyone may who sees it through a grant whose `can_download` is set —
@@ -590,12 +586,7 @@ pub trait Store: 'static + Send + Sync {
590 /// permissive grant on the chain wins: a download grant above the target586 /// permissive grant on the chain wins: a download grant above the target
591 /// opens the bytes even under a view-only grant on the target itself.587 /// opens the bytes even under a view-only grant on the target itself.
592 /// A view-only grant alone opens the page but not the bytes.588 /// A view-only grant alone opens the page but not the bytes.
593- async fn can_download(589+ async fn can_download(&self, kind: ShareKind, target_id: &str, user_id: &str) -> Result<bool>;
594- &self,
595- kind: ShareKind,
596- target_id: &str,
597- user_id: &str,
598- ) -> Result<bool>;
599 590
600 // -- chunked uploads ---------------------------------------------------591 // -- chunked uploads ---------------------------------------------------
601 592
@@ -619,12 +610,7 @@ pub trait Store: 'static + Send + Sync {
619 /// re-sending an index replaces its bytes rather than counting them610 /// re-sending an index replaces its bytes rather than counting them
620 /// twice. Anything past the declared total, or on a session that is not611 /// twice. Anything past the declared total, or on a session that is not
621 /// active and unexpired, is refused.612 /// active and unexpired, is refused.
622- async fn record_chunk(613+ async fn record_chunk(&self, id: &str, index: u64, bytes: &[u8]) -> Result<UploadSession>;
623- &self,
624- id: &str,
625- index: u64,
626- bytes: &[u8],
627- ) -> Result<UploadSession>;
628 614
629 /// Assembles a session's chunks in order, rechecks the quota, sniffs the615 /// Assembles a session's chunks in order, rechecks the quota, sniffs the
630 /// mime (never trusting anything the uploader said), writes the file,616 /// mime (never trusting anything the uploader said), writes the file,
@@ -658,10 +644,5 @@ pub trait Store: 'static + Send + Sync {
658 644
659 /// Owner-scoped substring search over live file and folder names, files645 /// Owner-scoped substring search over live file and folder names, files
660 /// and folders in their own lists. At most `limit` of each.646 /// and folders in their own lists. At most `limit` of each.
661- async fn search(647+ async fn search(&self, owner_id: &str, query: &str, limit: u32) -> Result<Listing>;
662- &self,
663- owner_id: &str,
664- query: &str,
665- limit: u32,
666- ) -> Result<Listing>;
667 }648 }
crates/in-web/src/drive.rsmodified+146 -27
@@ -63,6 +63,7 @@ struct DriveQuery {
63 sort: Option<String>,63 sort: Option<String>,
64 share: Option<String>,64 share: Option<String>,
65 kind: Option<String>,65 kind: Option<String>,
66+ r#move: Option<String>,
66 }67 }
67 68
68 /// The folder the query names, if it names one this account may open: owned,69 /// 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)>
137 out138 out
138 }139 }
139 140
141+/// The move picker's modal: `?move=kind:id` renders the drive root and every
142+/// live folder as one clickable row each over the page — the file-manager
143+/// idiom, replacing the select that used to sit inside the Options menu.
144+/// A folder's own subtree is left out: a move into itself or a descendant is
145+/// the store's refusal, and a row that can never be picked is noise. Sibling
146+/// names cannot collide (the store postfixes them), so the display path
147+/// identifies a subtree exactly. A pair naming nothing owned and live opens
148+/// nothing.
149+async fn move_modal(
150+ cx: &Cx,
151+ kind_raw: &str,
152+ target_id: &str,
153+ close_href: &str,
154+ destinations: &[(String, String)],
155+) -> Result<Option<topcoat::view::View>> {
156+ let user = match require_user(cx).await {
157+ Ok(user) => user,
158+ Err(_) => return Ok(None),
159+ };
160+ let language = lang(cx).await;
161+ let store = app(cx).store.clone();
162+ // The owned, live target, the endpoint its rows post to, and — for a
163+ // folder — the path prefix that marks its own subtree off the list.
164+ let (name, file, action, field, own_path): (
165+ String,
166+ Option<in_core::store::File>,
167+ &str,
168+ &str,
169+ Option<String>,
170+ ) = match kind_raw {
171+ "file" => {
172+ let Some(file) = store.file(target_id).await? else {
173+ return Ok(None);
174+ };
175+ if file.owner_id != user.id || file.deleted_at.is_some() {
176+ return Ok(None);
177+ }
178+ (
179+ file.name.clone(),
180+ Some(file),
181+ "/api/file/move",
182+ "folder_id",
183+ None,
184+ )
185+ }
186+ "folder" => {
187+ let Some(folder) = store.folder(target_id).await? else {
188+ return Ok(None);
189+ };
190+ if folder.owner_id != user.id || folder.deleted_at.is_some() {
191+ return Ok(None);
192+ }
193+ let own = destinations
194+ .iter()
195+ .find(|dest| dest.0 == target_id)
196+ .map(|dest| dest.1.clone());
197+ (
198+ folder.name.clone(),
199+ None,
200+ "/api/folder/move",
201+ "parent_id",
202+ own,
203+ )
204+ }
205+ _ => return Ok(None),
206+ };
207+ let subtree = own_path.map(|path| format!("{path} / "));
208+ let rows: Vec<&(String, String)> = destinations
209+ .iter()
210+ .filter(|dest| match &subtree {
211+ Some(prefix) => {
212+ !dest.1.starts_with(prefix.as_str()) && dest.1 != prefix.trim_end_matches(" / ")
213+ }
214+ None => true,
215+ })
216+ .collect();
217+ Ok(Some(view! {
218+ cx =>
219+ <div class="modal-scrim">
220+ <div class="modal move-modal">
221+ <div class="viewer-head">
222+ <h2 class="settings-title share-modal-title">
223+ if kind_raw == "folder" {
224+ <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span>
225+ }
226+ if let Some(file) = file.as_ref() {
227+ (crate::files::entry_chip(cx, file).await?)
228+ }
229+ (format!("{} “{}”", t(language, Key::Move), name.clone()))
230+ </h2>
231+ <div class="spacer"></div>
232+ <a class="quiet" href=(close_href.to_string()) aria-label=(t(language, Key::Close))>(t(language, Key::Close))</a>
233+ </div>
234+ <div class="move-list">
235+ <form class="move-dest" method="post" action=(action)>
236+ <input type="hidden" name="id" value=(target_id.to_string())>
237+ <input type="hidden" name=(field) value="">
238+ <button class="move-pick" type="submit">
239+ <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span>
240+ (t(language, Key::Drive))
241+ </button>
242+ </form>
243+ for dest in rows {
244+ <form class="move-dest" method="post" action=(action)>
245+ <input type="hidden" name="id" value=(target_id.to_string())>
246+ <input type="hidden" name=(field) value=(dest.0.clone())>
247+ <button class="move-pick" type="submit">
248+ <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span>
249+ (dest.1.clone())
250+ </button>
251+ </form>
252+ }
253+ </div>
254+ </div>
255+ </div>
256+ }?))
257+}
258+
140 fn human_size(bytes: u64) -> String {259 fn human_size(bytes: u64) -> String {
141 const UNITS: [&str; 5] = ["B", "KB", "MB", "GB", "TB"];260 const UNITS: [&str; 5] = ["B", "KB", "MB", "GB", "TB"];
142 let mut size = bytes as f64;261 let mut size = bytes as f64;
@@ -366,7 +485,13 @@ async fn drive(cx: &Cx) -> Result {
366 KindFilter::Files => found.folders.clear(),485 KindFilter::Files => found.folders.clear(),
367 }486 }
368 }487 }
369- let destinations = folder_tree(store.as_ref(), &user.id).await;488+ // The destination tree only pays when the move picker is open.
489+ let move_pair = params.as_ref().and_then(|query| query.r#move.as_deref());
490+ let destinations = if move_pair.is_some() {
491+ folder_tree(store.as_ref(), &user.id).await
492+ } else {
493+ Vec::new()
494+ };
370 let refusal = page_refusal(cx);495 let refusal = page_refusal(cx);
371 // Which folder row (if any) renders as its rename form: iz's `?edit=`496 // Which folder row (if any) renders as its rename form: iz's `?edit=`
372 // idiom — a server-side row swap, no client state to hold.497 // idiom — a server-side row swap, no client state to hold.
@@ -422,6 +547,14 @@ async fn drive(cx: &Cx) -> Result {
422 }547 }
423 None => None,548 None => None,
424 };549 };
550+ // The move picker: `?move=kind:id` renders the destination modal over
551+ // the page — one shot, unlike the share dialog: a posted move comes back
552+ // through `back_to`, which strips the pair, so the modal closes on both
553+ // success and refusal (the refusal then wears the page banner).
554+ let move_dialog = match move_pair.and_then(|pair| pair.split_once(':')) {
555+ Some((move_kind, id)) => move_modal(cx, move_kind, id, &here, &destinations).await?,
556+ None => None,
557+ };
425 // The copy-once banner belongs to the modal when it is open.558 // The copy-once banner belongs to the modal when it is open.
426 let created_panel = if share_pair.is_some() {559 let created_panel = if share_pair.is_some() {
427 None560 None
@@ -593,20 +726,8 @@ async fn drive(cx: &Cx) -> Result {
593 href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))</a>726 href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))</a>
594 <a class="user-menu-item"727 <a class="user-menu-item"
595 href=(format!("{here}{edit_sep}share=folder:{}", folder.id))>(t(language, Key::Share))</a>728 href=(format!("{here}{edit_sep}share=folder:{}", folder.id))>(t(language, Key::Share))</a>
596- <form class="user-menu-item-form" method="post" action="/api/folder/move">729+ <a class="user-menu-item"
597- <input type="hidden" name="id" value=(folder.id.clone())>730+ href=(format!("{here}{edit_sep}move=folder:{}", folder.id))>(t(language, Key::Move))</a>
598- <div class="user-menu-item-move">
599- <select class="field-input" name="parent_id" aria-label=(t(language, Key::MoveFolder))>
600- <option value="">(t(language, Key::Drive))</option>
601- for dest in destinations.iter() {
602- if dest.0 != folder.id {
603- <option value=(dest.0.clone())>(dest.1.clone())</option>
604- }
605- }
606- </select>
607- <button class="quiet" type="submit">(t(language, Key::Move))</button>
608- </div>
609- </form>
610 <form class="user-menu-item-form" method="post" action="/api/folder/delete">731 <form class="user-menu-item-form" method="post" action="/api/folder/delete">
611 <input type="hidden" name="id" value=(folder.id.clone())>732 <input type="hidden" name="id" value=(folder.id.clone())>
612 <button class="user-menu-item quiet quiet-danger" type="submit">(t(language, Key::Delete))</button>733 <button class="user-menu-item quiet quiet-danger" type="submit">(t(language, Key::Delete))</button>
@@ -644,18 +765,13 @@ async fn drive(cx: &Cx) -> Result {
644 href=(format!("{here}{edit_sep}edit={}", file.id))>(t(language, Key::Rename))</a>765 href=(format!("{here}{edit_sep}edit={}", file.id))>(t(language, Key::Rename))</a>
645 <a class="user-menu-item"766 <a class="user-menu-item"
646 href=(format!("{here}{edit_sep}share=file:{}", file.id))>(t(language, Key::Share))</a>767 href=(format!("{here}{edit_sep}share=file:{}", file.id))>(t(language, Key::Share))</a>
647- <form class="user-menu-item-form" method="post" action="/api/file/move">768+ // The `download` attribute keeps the
648- <input type="hidden" name="id" value=(file.id.clone())>769+ // soft-nav handler off the click, so the
649- <div class="user-menu-item-move">770+ // bytes land as a file, not a page swap.
650- <select class="field-input" name="folder_id" aria-label=(t(language, Key::MoveFile))>771+ <a class="user-menu-item"
651- <option value="">(t(language, Key::Drive))</option>772+ href=(format!("/file/{}?dl=1", file.id)) download="">(t(language, Key::Download))</a>
652- for dest in destinations.iter() {773+ <a class="user-menu-item"
653- <option value=(dest.0.clone())>(dest.1.clone())</option>774+ href=(format!("{here}{edit_sep}move=file:{}", file.id))>(t(language, Key::Move))</a>
654- }
655- </select>
656- <button class="quiet" type="submit">(t(language, Key::Move))</button>
657- </div>
658- </form>
659 <form class="user-menu-item-form" method="post" action="/api/file/delete">775 <form class="user-menu-item-form" method="post" action="/api/file/delete">
660 <input type="hidden" name="id" value=(file.id.clone())>776 <input type="hidden" name="id" value=(file.id.clone())>
661 <button class="user-menu-item quiet quiet-danger" type="submit">(t(language, Key::Delete))</button>777 <button class="user-menu-item quiet quiet-danger" type="submit">(t(language, Key::Delete))</button>
@@ -669,6 +785,9 @@ async fn drive(cx: &Cx) -> Result {
669 </section>785 </section>
670 }786 }
671 </main>787 </main>
788+ if let Some(dialog) = move_dialog {
789+ (dialog)
790+ }
672 if let Some(dialog) = share_dialog {791 if let Some(dialog) = share_dialog {
673 (dialog)792 (dialog)
674 }793 }
crates/in-web/src/files.rsmodified+9 -5
@@ -201,7 +201,8 @@ async fn visible_file(
201 201
202 /// Serves one file's bytes, or the same not-found a stranger would see for202 /// Serves one file's bytes, or the same not-found a stranger would see for
203 /// a file that does not exist — never a `403`, which would confirm the id203 /// a file that does not exist — never a `403`, which would confirm the id
204-/// belongs to somebody else's drive.204+/// belongs to somebody else's drive. Only `?dl=1` counts a download: the
205+/// viewer reads the same bytes inline, and looking is not downloading.
205 #[route(GET "/file/{id}")]206 #[route(GET "/file/{id}")]
206 async fn download(cx: &Cx) -> topcoat::Result<(StatusCode, HeaderMap, Vec<u8>)> {207 async fn download(cx: &Cx) -> topcoat::Result<(StatusCode, HeaderMap, Vec<u8>)> {
207 let id: &str = path_param::<Id>(cx);208 let id: &str = path_param::<Id>(cx);
@@ -267,9 +268,10 @@ async fn download(cx: &Cx) -> topcoat::Result<(StatusCode, HeaderMap, Vec<u8>)>
267 .and_then(|value| value.to_str().ok());268 .and_then(|value| value.to_str().ok());
268 match range.and_then(|range| parse_range(range, total)) {269 match range.and_then(|range| parse_range(range, total)) {
269 Some(Ok((start, end))) => {270 Some(Ok((start, end))) => {
270- // A play counts once, on its first chunk; later seeks are the271+ // Only a real download counts — `?dl=1` — never the viewer's
271- // same view going on, not a new one.272+ // inline bytes. A resumed download counts once, on its first
272- if start == 0 {273+ // chunk; later chunks are the same download going on.
274+ if forced && start == 0 {
273 let _ = store.record_download(id).await;275 let _ = store.record_download(id).await;
274 }276 }
275 let slice = bytes[start as usize..=end as usize].to_vec();277 let slice = bytes[start as usize..=end as usize].to_vec();
@@ -287,7 +289,9 @@ async fn download(cx: &Cx) -> topcoat::Result<(StatusCode, HeaderMap, Vec<u8>)>
287 Ok((StatusCode::RANGE_NOT_SATISFIABLE, headers, Vec::new()))289 Ok((StatusCode::RANGE_NOT_SATISFIABLE, headers, Vec::new()))
288 }290 }
289 None => {291 None => {
290- let _ = store.record_download(id).await;292+ if forced {
293+ let _ = store.record_download(id).await;
294+ }
291 Ok((StatusCode::OK, headers, bytes))295 Ok((StatusCode::OK, headers, bytes))
292 }296 }
293 }297 }
crates/in-web/src/i18n.rsmodified+0 -6
@@ -102,7 +102,6 @@ pub enum Key {
102 FolderName,102 FolderName,
103 CreateFolder,103 CreateFolder,
104 RenameFolder,104 RenameFolder,
105- MoveFolder,
106 DeleteFolder,105 DeleteFolder,
107 EmptyFolder,106 EmptyFolder,
108 FoldersHeading,107 FoldersHeading,
@@ -126,7 +125,6 @@ pub enum Key {
126 FileDetails,125 FileDetails,
127 PreviewUnavailable,126 PreviewUnavailable,
128 RenameFile,127 RenameFile,
129- MoveFile,
130 DeleteFile,128 DeleteFile,
131 // Share.129 // Share.
132 Share,130 Share,
@@ -255,7 +253,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
255 FolderName => "Folder name",253 FolderName => "Folder name",
256 CreateFolder => "Create folder",254 CreateFolder => "Create folder",
257 RenameFolder => "Rename folder",255 RenameFolder => "Rename folder",
258- MoveFolder => "Move folder",
259 DeleteFolder => "Delete folder",256 DeleteFolder => "Delete folder",
260 EmptyFolder => {257 EmptyFolder => {
261 "This folder is empty. Press + to create or upload, or drop files on this page."258 "This folder is empty. Press + to create or upload, or drop files on this page."
@@ -279,7 +276,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
279 FileDetails => "File",276 FileDetails => "File",
280 PreviewUnavailable => "No preview for this kind of file.",277 PreviewUnavailable => "No preview for this kind of file.",
281 RenameFile => "Rename file",278 RenameFile => "Rename file",
282- MoveFile => "Move file",
283 DeleteFile => "Delete file",279 DeleteFile => "Delete file",
284 Share => "Share",280 Share => "Share",
285 ShareLink => "Share link",281 ShareLink => "Share link",
@@ -394,7 +390,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
394 FolderName => "Klasör adı",390 FolderName => "Klasör adı",
395 CreateFolder => "Klasörü oluştur",391 CreateFolder => "Klasörü oluştur",
396 RenameFolder => "Klasörü yeniden adlandır",392 RenameFolder => "Klasörü yeniden adlandır",
397- MoveFolder => "Klasörü taşı",
398 DeleteFolder => "Klasörü sil",393 DeleteFolder => "Klasörü sil",
399 EmptyFolder => {394 EmptyFolder => {
400 "Bu klasör boş. + ile oluştur ya da yükle, ya da dosyaları bu sayfaya bırak."395 "Bu klasör boş. + ile oluştur ya da yükle, ya da dosyaları bu sayfaya bırak."
@@ -418,7 +413,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
418 FileDetails => "Dosya",413 FileDetails => "Dosya",
419 PreviewUnavailable => "Bu tür dosyanın önizlemesi yok.",414 PreviewUnavailable => "Bu tür dosyanın önizlemesi yok.",
420 RenameFile => "Dosyayı yeniden adlandır",415 RenameFile => "Dosyayı yeniden adlandır",
421- MoveFile => "Dosyayı taşı",
422 DeleteFile => "Dosyayı sil",416 DeleteFile => "Dosyayı sil",
423 Share => "Paylaş",417 Share => "Paylaş",
424 ShareLink => "Paylaşım bağlantısı",418 ShareLink => "Paylaşım bağlantısı",
crates/in-web/src/layout.rsmodified+1 -1
@@ -535,7 +535,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
535 scrims.forEach(function (el) { el.remove(); }); \535 scrims.forEach(function (el) { el.remove(); }); \
536 sweepPanels(); \536 sweepPanels(); \
537 var u = new URL(window.location.href); \537 var u = new URL(window.location.href); \
538- ['task', 'file', 'confirm', 'new', 'refusal', 'on', 'share', 'created'].forEach(function (k) { u.searchParams.delete(k); }); \538+ ['task', 'file', 'confirm', 'new', 'refusal', 'on', 'share', 'created', 'move'].forEach(function (k) { u.searchParams.delete(k); }); \
539 var q = u.searchParams.toString(); \539 var q = u.searchParams.toString(); \
540 history.replaceState(null, '', u.pathname + (q ? '?' + q : '')); \540 history.replaceState(null, '', u.pathname + (q ? '?' + q : '')); \
541 return true; \541 return true; \
crates/in-web/src/server.rsmodified+3 -2
@@ -396,7 +396,8 @@ pub fn refusal_of(cx: &Cx, call: &str) -> Option<Refusal> {
396 /// came with the request.396 /// came with the request.
397 ///397 ///
398 /// The feedback pairs — `refusal=`, `on=`, `why=`, `saved=` — are how a page398 /// The feedback pairs — `refusal=`, `on=`, `why=`, `saved=` — are how a page
399-/// renders what the last post did. Sending the browser back with them still399+/// renders what the last post did, and `move=` opens the drive's one-shot
400+/// destination picker, which no post should return to. Sending the browser
400 /// on the query re-renders that old answer under the new post's own: a change401 /// on the query re-renders that old answer under the new post's own: a change
401 /// that succeeded right after one that was refused announces the refusal402 /// that succeeded right after one that was refused announces the refusal
402 /// again, and reads as having failed. The answer this redirect carries — the403 /// again, and reads as having failed. The answer this redirect carries — the
@@ -413,7 +414,7 @@ pub fn back_to(cx: &Cx, nowhere: &str) -> String {
413 .split('&')414 .split('&')
414 .filter(|pair| {415 .filter(|pair| {
415 !pair.is_empty()416 !pair.is_empty()
416- && !["refusal", "on", "why", "saved"].iter().any(|key| {417+ && !["refusal", "on", "why", "saved", "move"].iter().any(|key| {
417 pair.strip_prefix(*key)418 pair.strip_prefix(*key)
418 .is_some_and(|rest| rest.starts_with('='))419 .is_some_and(|rest| rest.starts_with('='))
419 })420 })
crates/in-web/tests/http.rsmodified+99 -1
@@ -1262,6 +1262,74 @@ async fn forced_download_is_attachment() {
1262 assert_eq!(forced.bytes, b"read me");1262 assert_eq!(forced.bytes, b"read me");
1263 }1263 }
1264 1264
1265+/// Looking is not downloading: the viewer's inline serves — the plain GET
1266+/// and a media element's range probe from byte 0 — never move the counter;
1267+/// only the `?dl=1` disposition does, once per download.
1268+#[tokio::test]
1269+async fn previews_do_not_count_as_downloads() {
1270+ let app = TestApp::build().await;
1271+ let cookie = app.sign_in("sub-prev", "prev@in.test", "Prev").await;
1272+ let user = app
1273+ .store
1274+ .user_by_oidc_sub("sub-prev")
1275+ .await
1276+ .unwrap()
1277+ .unwrap();
1278+
1279+ app.post_multipart(
1280+ "/files",
1281+ Some(&cookie),
1282+ &[("folder_id", "")],
1283+ &[("clip.txt", "text/plain", b"counted only when taken")],
1284+ )
1285+ .await;
1286+ let file = app
1287+ .store
1288+ .list_children(&user.id, None)
1289+ .await
1290+ .unwrap()
1291+ .files
1292+ .into_iter()
1293+ .next()
1294+ .unwrap();
1295+ let count = || async {
1296+ app.store
1297+ .file(&file.id)
1298+ .await
1299+ .unwrap()
1300+ .unwrap()
1301+ .download_count
1302+ };
1303+
1304+ let inline = app.get(&format!("/file/{}", file.id), Some(&cookie)).await;
1305+ assert_eq!(inline.status, StatusCode::OK);
1306+ let probe = app
1307+ .get_with_range(&format!("/file/{}", file.id), Some(&cookie), "bytes=0-3")
1308+ .await;
1309+ assert_eq!(probe.status, StatusCode::PARTIAL_CONTENT);
1310+ assert_eq!(
1311+ count().await,
1312+ 0,
1313+ "previews counted: inline and range serves"
1314+ );
1315+
1316+ let taken = app
1317+ .get(&format!("/file/{}?dl=1", file.id), Some(&cookie))
1318+ .await;
1319+ assert_eq!(taken.status, StatusCode::OK);
1320+ assert_eq!(count().await, 1, "a forced download did not count");
1321+ // A mid-file chunk of a download is the same download going on.
1322+ let resumed = app
1323+ .get_with_range(
1324+ &format!("/file/{}?dl=1", file.id),
1325+ Some(&cookie),
1326+ "bytes=4-",
1327+ )
1328+ .await;
1329+ assert_eq!(resumed.status, StatusCode::PARTIAL_CONTENT);
1330+ assert_eq!(count().await, 1, "a resumed chunk counted again");
1331+}
1332+
1265 // -- public links (merged from http_d2.rs; one binary per crate) ------------1333 // -- public links (merged from http_d2.rs; one binary per crate) ------------
1266 1334
1267 #[tokio::test]1335 #[tokio::test]
@@ -3152,7 +3220,37 @@ async fn drive_lists_folders_before_files_in_one_panel() {
3152 let folder_at = body.find("mmm folder").expect("no folder row");3220 let folder_at = body.find("mmm folder").expect("no folder row");
3153 let file_at = body.find("aaa file.txt").expect("no file row");3221 let file_at = body.find("aaa file.txt").expect("no file row");
3154 assert!(folder_at < file_at, "file row precedes folder row: {body}");3222 assert!(folder_at < file_at, "file row precedes folder row: {body}");
3155- assert!(body.contains("action=\"/api/folder/move\""), "{body}");3223+ // Move is a picker modal now: the row's menu links to it, and the modal
3224+ // carries the destination rows that post the move.
3225+ let folder_id = {
3226+ let at = body.find("/drive?folder=").expect("no folder link");
3227+ let rest = &body[at + "/drive?folder=".len()..];
3228+ let end = rest.find('"').expect("unterminated folder link");
3229+ rest[..end].to_string()
3230+ };
3231+ assert!(
3232+ body.contains(&format!("move=folder:{folder_id}")),
3233+ "folder row has no move entry: {body}"
3234+ );
3235+ assert!(
3236+ body.contains(&format!("move=file:{file_id}")),
3237+ "file row has no move entry: {body}"
3238+ );
3239+ let picker = app
3240+ .get(&format!("/drive?move=folder:{folder_id}"), Some(&cookie))
3241+ .await;
3242+ let picker_body = picker.text();
3243+ assert!(
3244+ picker_body.contains("action=\"/api/folder/move\""),
3245+ "{picker_body}"
3246+ );
3247+ // A folder never offers its own subtree as a destination: with only the
3248+ // target folder in the tree, the drive root is the one row left.
3249+ assert_eq!(
3250+ picker_body.matches("class=\"move-pick\"").count(),
3251+ 1,
3252+ "{picker_body}"
3253+ );
3156 // File rename follows the folder pattern: an edit link on the plain3254 // File rename follows the folder pattern: an edit link on the plain
3157 // view, the form only on the edit view.3255 // view, the form only on the edit view.
3158 assert!(3256 assert!(
style/main.scssmodified+35 -24
@@ -4432,19 +4432,6 @@ input[type="radio"] {
4432 &::marker, &::-webkit-details-marker { display: none; }4432 &::marker, &::-webkit-details-marker { display: none; }
4433 }4433 }
4434 4434
4435-// The move form inside the menu: picker and submit side by side, padded like
4436-// the link items around them.
4437-.user-menu-item-move {
4438- display: flex;
4439- align-items: center;
4440- gap: 8px;
4441- padding: 4px 14px;
4442-
4443- .field-input {
4444- flex: 1;
4445- min-width: 0;
4446- }
4447-}
4448 4435
4449 // The rename row: the form itself fills the row so the input takes the4436 // The rename row: the form itself fills the row so the input takes the
4450 // middle and Rename/Cancel sit at the right edge, exactly where the Options4437 // middle and Rename/Cancel sit at the right edge, exactly where the Options
@@ -4851,9 +4838,8 @@ div.member-row + div.member-row {
4851 // -- entry Options menu: flat rows, no boxed buttons -------------------------4838 // -- entry Options menu: flat rows, no boxed buttons -------------------------
4852 //4839 //
4853 // Inside the menu, `.quiet`'s border box reads as a second frame (his round-44840 // Inside the menu, `.quiet`'s border box reads as a second frame (his round-4
4854-// screenshot): the Delete and Move submits become flat menu rows like the4841+// screenshot): the Delete submit becomes a flat menu row like the
4855-// Rename/Share links — Delete keeps only its danger ink, Move only the4842+// Rename/Share/Move links around it, keeping only its danger ink.
4856-// accent. The Move row's select trigger keeps the house chevron.
4857 .entry-options .user-menu-panel .quiet {4843 .entry-options .user-menu-panel .quiet {
4858 border: none;4844 border: none;
4859 background: none;4845 background: none;
@@ -4872,15 +4858,40 @@ div.member-row + div.member-row {
4872 4858
4873 &:hover { background: var(--row-hover); color: var(--danger); border: none; }4859 &:hover { background: var(--row-hover); color: var(--danger); border: none; }
4874 }4860 }
4875-// The Move submit sits beside its select, not under it: compact, accent-ink,4861+// -- the move destination picker ---------------------------------------------
4876-// no full-width row there.4862+//
4877-.entry-options .user-menu-panel .user-menu-item-move .quiet {4863+// The explorer-style list the Options menu's Move item opens: one full-width
4878- width: auto;4864+// row per destination, padded and hovered like the menu items it replaced.
4879- flex: none;4865+.move-modal {
4880- padding: 0 2px;4866+ width: 480px;
4881- color: var(--accent);4867+ padding: 18px 20px 20px;
4868+}
4869+.move-modal .viewer-head {
4870+ margin: 0 0 12px;
4871+}
4872+.move-list {
4873+ max-height: calc(100vh - 280px);
4874+ overflow-y: auto;
4875+}
4876+.move-dest { display: block; }
4877+.move-dest + .move-dest { margin-top: 2px; }
4878+.move-pick {
4879+ display: flex;
4880+ align-items: center;
4881+ gap: 8px;
4882+ width: 100%;
4883+ height: 34px;
4884+ padding: 0 10px;
4885+ border: none;
4886+ border-radius: var(--radius);
4887+ background: none;
4888+ font-family: inherit;
4889+ font-size: 13px;
4890+ color: var(--ink-soft);
4891+ text-align: left;
4892+ cursor: pointer;
4882 4893
4883- &:hover { background: none; color: var(--accent-ink); }4894+ &:hover { background: var(--row-hover); color: var(--ink); }
4884 }4895 }
4885 4896
4886 // -- the share modal ---------------------------------------------------------4897 // -- the share modal ---------------------------------------------------------