Export to an album instead of a folder in the settings
Export took a path typed into the settings page, or a folder inside the library on the server. The first is how exports end up somewhere nobody looks; the second put JPEGs into the tree a scan catalogues, where they came back as photographs beside the RAWs they were made from. The destination is now an album (FR-EXP-10), chosen by name in the export sheet. Albums are listed under the collections in the sidebar; "+" there, or "New album…" in the sheet, opens a sheet for its name and its folder — on this device through the platform's dialogue, or on the server through the browser with "New folder". A server folder inside the library is refused, and the sheet says why. Selecting an album narrows the grid to the photographs behind its files: library::Scope is Collection or Album, and scope_clause is the one place the two are spelled, which also retires the two copies of the collection predicate total_images_scoped and read_cells_scoped had inlined. A batch resolves the album when it starts, and refuses in words when none is chosen, it has gone, or its folder is local to another device. Each item reports the image it came from, and the files written are recorded against the album in one transaction when the batch ends. A server album lives outside the library, so its queued uploads are relative to the account root. That is a third line in the outbox's .dest record rather than a leading slash, because a record written before albums may carry a stray slash and must keep the meaning it was written with. An export folder set before albums becomes an album called "Exports" on first open, so upgrading does not lose where exports were going. The old destination fields stay in ExportSettings so older settings files still read.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
//! for, trash listing, and the ordinal a single photograph sits at.
|
||||
|
||||
use dr_catalog::Catalog;
|
||||
|
||||
use super::Scope;
|
||||
#[cfg(test)]
|
||||
use dr_sync::RemotePath;
|
||||
#[cfg(test)]
|
||||
@@ -82,39 +84,29 @@ pub fn read_cells(
|
||||
/// positions are unrelated integers.
|
||||
pub fn read_cells_scoped(
|
||||
catalog: &Catalog,
|
||||
scope: Option<dr_types::CollectionId>,
|
||||
scope: Option<Scope>,
|
||||
filter: &RatingFilter,
|
||||
offset: usize,
|
||||
limit: usize,
|
||||
) -> Result<Vec<LibraryCell>, dr_catalog::CatalogError> {
|
||||
let Some(scope) = scope else {
|
||||
if scope.is_none() {
|
||||
return read_cells_all(catalog, filter, offset, limit);
|
||||
};
|
||||
}
|
||||
|
||||
let ids = dr_catalog::collections::descendants(catalog.connection(), scope)?;
|
||||
// Placeholders are generated from the *count* of ids, never from user text.
|
||||
let placeholders = std::iter::repeat_n("?", ids.len())
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
let (clause, mut params) = scope_clause(catalog, scope)?;
|
||||
let rated = filter.sql();
|
||||
let folded = uncollapsed("i");
|
||||
let (order, order_params) = grid_order_for(catalog, Some(scope));
|
||||
let (order, order_params) = grid_order_for(catalog, scope);
|
||||
let sql = format!(
|
||||
"SELECT {CELL_COLUMNS}
|
||||
FROM images i
|
||||
WHERE {VISIBLE}{rated}{folded}
|
||||
AND i.id IN (SELECT image_id FROM collection_members
|
||||
WHERE collection_id IN ({placeholders}))
|
||||
WHERE {VISIBLE}{rated}{folded}{clause}
|
||||
{order}
|
||||
LIMIT ? OFFSET ?"
|
||||
);
|
||||
|
||||
// Bound in the order the `?`s appear: the scope's ids in the WHERE, then
|
||||
// Bound in the order the `?`s appear: the scope's in the WHERE, then
|
||||
// whatever the ORDER BY needs, then the window.
|
||||
let mut params: Vec<rusqlite::types::Value> = ids
|
||||
.iter()
|
||||
.map(|c| rusqlite::types::Value::Integer(c.0 as i64))
|
||||
.collect();
|
||||
params.extend(order_params);
|
||||
params.push(rusqlite::types::Value::Integer(limit as i64));
|
||||
params.push(rusqlite::types::Value::Integer(offset as i64));
|
||||
@@ -225,7 +217,7 @@ pub fn total_trashed(catalog: &Catalog) -> Result<usize, dr_catalog::CatalogErro
|
||||
/// the two the same, because both leave the selection where it was.
|
||||
pub fn read_ids_span(
|
||||
catalog: &Catalog,
|
||||
scope: Option<dr_types::CollectionId>,
|
||||
scope: Option<Scope>,
|
||||
filter: &RatingFilter,
|
||||
trash: bool,
|
||||
first: usize,
|
||||
@@ -310,7 +302,7 @@ pub fn read_ids_span(
|
||||
/// narrows. Swapping the two silently looks up a collection by an image id.
|
||||
pub fn ordinal_of_path(
|
||||
catalog: &Catalog,
|
||||
scope: Option<dr_types::CollectionId>,
|
||||
scope: Option<Scope>,
|
||||
filter: &RatingFilter,
|
||||
trash: bool,
|
||||
path: &str,
|
||||
@@ -669,18 +661,18 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
let filter = RatingFilter::default();
|
||||
let cells = read_cells_scoped(&catalog, Some(coll), &filter, 0, 100).unwrap();
|
||||
let cells = read_cells_scoped(&catalog, Some(Scope::Collection(coll)), &filter, 0, 100).unwrap();
|
||||
assert_eq!(cells.len(), 2);
|
||||
for (i, cell) in cells.iter().enumerate() {
|
||||
assert_eq!(
|
||||
ordinal_of_path(&catalog, Some(coll), &filter, false, &cell.remote_path).unwrap(),
|
||||
ordinal_of_path(&catalog, Some(Scope::Collection(coll)), &filter, false, &cell.remote_path).unwrap(),
|
||||
Some(i),
|
||||
"{} is drawn at row {i} of the collection",
|
||||
cell.remote_path
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
ordinal_of_path(&catalog, Some(coll), &filter, false, "2019/a.CR2").unwrap(),
|
||||
ordinal_of_path(&catalog, Some(Scope::Collection(coll)), &filter, false, "2019/a.CR2").unwrap(),
|
||||
None,
|
||||
"not a member"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user