Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb5ff8b8da | ||
|
|
c57d98799a | ||
|
|
7d9d5850a4 | ||
|
|
a69ebbdd10 | ||
|
|
ddf7335894 | ||
|
|
140bd2eee3 | ||
|
|
2462cb24bd | ||
|
|
a1dd2b5a9b | ||
|
|
e9d6d4a907 | ||
|
|
6fa91e83f1 | ||
|
|
f239dffbcc | ||
|
|
f2c4c05f27 | ||
|
|
7d445bb02c |
No files matched your search
@@ -105,14 +105,17 @@ jobs:
|
|||||||
- name: Simulation runs
|
- name: Simulation runs
|
||||||
run: 'cargo test -p pdfs-fuse --lib --locked sim:: -- --ignored --test-threads=1'
|
run: 'cargo test -p pdfs-fuse --lib --locked sim:: -- --ignored --test-threads=1'
|
||||||
|
|
||||||
# A hung step writes every daemon thread's stack next to the run's
|
# Retain the operation trace and daemon logs for the failing seed, plus
|
||||||
# state; without them a hang that does not replay cannot be told apart.
|
# every daemon thread's stack if the watchdog caught a hang.
|
||||||
- name: Keep the stacks of a hung run
|
- name: Keep simulation failure diagnostics
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: simulation-stacks
|
name: simulation-diagnostics
|
||||||
path: /tmp/pdfs-sim-*/stacks.txt
|
path: |
|
||||||
|
/tmp/pdfs-sim-*/steps.log
|
||||||
|
/tmp/pdfs-sim-*/daemon.log
|
||||||
|
/tmp/pdfs-sim-*/stacks.txt
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|
||||||
# Keeps the release-profile dependencies cached on main, where the release
|
# Keeps the release-profile dependencies cached on main, where the release
|
||||||
|
|||||||
@@ -129,8 +129,12 @@ jobs:
|
|||||||
# Every crate the build needs, so COPR can build the spec without network.
|
# Every crate the build needs, so COPR can build the spec without network.
|
||||||
- name: Package vendored crates (.tar.xz)
|
- name: Package vendored crates (.tar.xz)
|
||||||
run: |
|
run: |
|
||||||
cargo vendor --locked dist/vendor > /dev/null
|
mkdir -p dist/.cargo
|
||||||
tar -cJf proton-drive-linux-vendor-${{ env.VERSION }}.tar.xz -C dist vendor
|
(
|
||||||
|
cd dist
|
||||||
|
cargo vendor --locked --manifest-path ../Cargo.toml vendor > .cargo/config.toml
|
||||||
|
)
|
||||||
|
tar -cJf proton-drive-linux-vendor-${{ env.VERSION }}.tar.xz -C dist vendor .cargo/config.toml
|
||||||
|
|
||||||
- name: Package Debian package (.deb)
|
- name: Package Debian package (.deb)
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ dependencies = [
|
|||||||
"cipher 0.5.2",
|
"cipher 0.5.2",
|
||||||
"cpubits",
|
"cpubits",
|
||||||
"cpufeatures 0.3.1",
|
"cpufeatures 0.3.1",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -77,6 +78,7 @@ dependencies = [
|
|||||||
"ctr 0.10.1",
|
"ctr 0.10.1",
|
||||||
"ctutils",
|
"ctutils",
|
||||||
"ghash 0.6.0",
|
"ghash 0.6.0",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1878,6 +1880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5"
|
checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"polyval 0.7.3",
|
"polyval 0.7.3",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2237,6 +2240,12 @@ version = "1.10.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
|
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "httpdate"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hybrid-array"
|
name = "hybrid-array"
|
||||||
version = "0.4.15"
|
version = "0.4.15"
|
||||||
@@ -2260,6 +2269,7 @@ dependencies = [
|
|||||||
"http",
|
"http",
|
||||||
"http-body",
|
"http-body",
|
||||||
"httparse",
|
"httparse",
|
||||||
|
"httpdate",
|
||||||
"itoa",
|
"itoa",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -3582,7 +3592,7 @@ checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdfs-cli"
|
name = "pdfs-cli"
|
||||||
version = "3.8.0"
|
version = "3.8.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -3599,8 +3609,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdfs-core"
|
name = "pdfs-core"
|
||||||
version = "3.8.0"
|
version = "3.8.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"argon2",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3629,18 +3640,24 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdfs-fuse"
|
name = "pdfs-fuse"
|
||||||
version = "3.8.0"
|
version = "3.8.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
"fuser",
|
"fuser",
|
||||||
"futures",
|
"futures",
|
||||||
|
"getrandom 0.4.3",
|
||||||
|
"http-body-util",
|
||||||
|
"hyper",
|
||||||
|
"hyper-util",
|
||||||
"image",
|
"image",
|
||||||
"libc",
|
"libc",
|
||||||
"lofty",
|
"lofty",
|
||||||
"notify",
|
"notify",
|
||||||
"parking_lot 0.13.0",
|
"parking_lot 0.13.0",
|
||||||
"pdfs-core",
|
"pdfs-core",
|
||||||
|
"pg-app",
|
||||||
|
"pg-core",
|
||||||
"proton-drive-rs",
|
"proton-drive-rs",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -3648,15 +3665,17 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"zeroize",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdfs-gui"
|
name = "pdfs-gui"
|
||||||
version = "3.8.0"
|
version = "3.8.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-channel",
|
"async-channel",
|
||||||
|
"base64 0.23.1",
|
||||||
"gettext-rs",
|
"gettext-rs",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
"kamadak-exif",
|
"kamadak-exif",
|
||||||
@@ -3664,6 +3683,7 @@ dependencies = [
|
|||||||
"libadwaita",
|
"libadwaita",
|
||||||
"pangocairo",
|
"pangocairo",
|
||||||
"pdfs-core",
|
"pdfs-core",
|
||||||
|
"pg-core",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -3688,6 +3708,65 @@ version = "2.3.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pg-app"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "git+https://github.com/narrrl/proton-gallery.git?rev=72d83a29ad2836c698b18e2f5189a423c60c2399#72d83a29ad2836c698b18e2f5189a423c60c2399"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"hex",
|
||||||
|
"pg-core",
|
||||||
|
"pg-drive",
|
||||||
|
"proton-drive-rs",
|
||||||
|
"proton-sdk",
|
||||||
|
"serde_json",
|
||||||
|
"sha2 0.11.1",
|
||||||
|
"tempfile",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pg-core"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "git+https://github.com/narrrl/proton-gallery.git?rev=72d83a29ad2836c698b18e2f5189a423c60c2399#72d83a29ad2836c698b18e2f5189a423c60c2399"
|
||||||
|
dependencies = [
|
||||||
|
"aes-gcm 0.11.1",
|
||||||
|
"async-trait",
|
||||||
|
"getrandom 0.4.3",
|
||||||
|
"hex",
|
||||||
|
"rusqlite",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha2 0.11.1",
|
||||||
|
"tempfile",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
"tokio",
|
||||||
|
"tokio-util",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pg-drive"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "git+https://github.com/narrrl/proton-gallery.git?rev=72d83a29ad2836c698b18e2f5189a423c60c2399#72d83a29ad2836c698b18e2f5189a423c60c2399"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"hex",
|
||||||
|
"pg-core",
|
||||||
|
"proton-drive-rs",
|
||||||
|
"proton-sdk",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha2 0.11.1",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pgp"
|
name = "pgp"
|
||||||
version = "0.21.0"
|
version = "0.21.0"
|
||||||
@@ -3825,6 +3904,7 @@ dependencies = [
|
|||||||
"cpubits",
|
"cpubits",
|
||||||
"cpufeatures 0.3.1",
|
"cpufeatures 0.3.1",
|
||||||
"universal-hash 0.6.1",
|
"universal-hash 0.6.1",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3893,9 +3973,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proton-drive-rs"
|
name = "proton-drive-rs"
|
||||||
version = "0.12.0"
|
version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4265c2cf3bdc59ee273d7363c8b6a7cb4e98be6102ffa18144c4d8ebda00737b"
|
checksum = "d05ad4be849ce2104759631063dd06867fbe6b6f0e5c37a172a84b5a90203fa7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
@@ -3921,9 +4001,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proton-sdk"
|
name = "proton-sdk"
|
||||||
version = "0.12.0"
|
version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fb98ab3e336ed95f82368a50348dad00e5fc919e982d748e83e844afcadbd5d8"
|
checksum = "80c381e9066c0bca3c32597df2e902eecaa4c6e05e202e70ec9d0ac2eec78bfe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm 0.11.1",
|
"aes-gcm 0.11.1",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -5191,6 +5271,7 @@ dependencies = [
|
|||||||
"bytes",
|
"bytes",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
|
"futures-util",
|
||||||
"libc",
|
"libc",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ resolver = "2"
|
|||||||
members = ["crates/pdfs-core", "crates/pdfs-fuse", "crates/pdfs-cli", "crates/pdfs-gui"]
|
members = ["crates/pdfs-core", "crates/pdfs-fuse", "crates/pdfs-cli", "crates/pdfs-gui"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "3.8.0"
|
version = "3.8.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Nils Pukropp <contact@narl.io>"]
|
authors = ["Nils Pukropp <contact@narl.io>"]
|
||||||
@@ -15,8 +15,10 @@ keywords = ["proton", "drive", "fuse", "sync", "linux"]
|
|||||||
categories = ["filesystem", "command-line-utilities"]
|
categories = ["filesystem", "command-line-utilities"]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
proton-sdk = { version = "0.12.0" }
|
proton-sdk = { version = "0.12.1" }
|
||||||
proton-drive-rs = { version = "0.12.0" }
|
proton-drive-rs = { version = "0.12.1" }
|
||||||
|
pg-app = { git = "https://github.com/narrrl/proton-gallery.git", rev = "72d83a29ad2836c698b18e2f5189a423c60c2399" }
|
||||||
|
pg-core = { git = "https://github.com/narrrl/proton-gallery.git", rev = "72d83a29ad2836c698b18e2f5189a423c60c2399" }
|
||||||
chrono = { version = "0.4", default-features = false, features = ["std"] }
|
chrono = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
# Internal crates.
|
# Internal crates.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<img src="images/logo.svg" alt="" width="112" height="112">
|
<a href="images/logo.svg"><img src="images/logo.svg" alt="Proton Drive for Linux icon" width="128" height="128"></a>
|
||||||
|
|
||||||
# Proton Drive for Linux
|
# Proton Drive for Linux
|
||||||
|
|
||||||
|
|||||||
@@ -1511,6 +1511,7 @@ fn issue_text(issue: SyncIssue) -> &'static str {
|
|||||||
"you can no longer change this on Proton Drive, for example because a share was \
|
"you can no longer change this on Proton Drive, for example because a share was \
|
||||||
revoked. Save a copy to keep the content."
|
revoked. Save a copy to keep the content."
|
||||||
}
|
}
|
||||||
|
SyncIssue::Trashed => "restore the item or folder from Trash, then retry the move.",
|
||||||
SyncIssue::Missing => {
|
SyncIssue::Missing => {
|
||||||
"the file or its folder is gone from Proton Drive. Save a copy to keep the content."
|
"the file or its folder is gone from Proton Drive. Save a copy to keep the content."
|
||||||
}
|
}
|
||||||
@@ -2695,6 +2696,7 @@ fn mount_once(mountpoint: Option<PathBuf>) -> Result<pdfs_fuse::MountOutcome> {
|
|||||||
db,
|
db,
|
||||||
pdfs_fuse::MountOptions {
|
pdfs_fuse::MountOptions {
|
||||||
username,
|
username,
|
||||||
|
gallery_session: Some(session.clone()),
|
||||||
sweep_mode: config.resolved_conflict_sweep(),
|
sweep_mode: config.resolved_conflict_sweep(),
|
||||||
upload_limit: config.upload_limit.unwrap_or(0),
|
upload_limit: config.upload_limit.unwrap_or(0),
|
||||||
download_limit: config.download_limit.unwrap_or(0),
|
download_limit: config.download_limit.unwrap_or(0),
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ homepage.workspace = true
|
|||||||
description = "Core auth/session/config for the Proton Drive Linux client"
|
description = "Core auth/session/config for the Proton Drive Linux client"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
argon2 = "0.5"
|
||||||
proton-sdk.workspace = true
|
proton-sdk.workspace = true
|
||||||
proton-drive-rs.workspace = true
|
proton-drive-rs.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
|
|||||||
@@ -128,6 +128,48 @@ fn with_keyring<T>(op: impl Fn(&Entry) -> keyring_core::Result<T>) -> Result<T>
|
|||||||
with_keyring_entry(KEYRING_SERVICE, KEYRING_USER, op)
|
with_keyring_entry(KEYRING_SERVICE, KEYRING_USER, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Verify the machine-local Gallery passphrase, setting it on first use.
|
||||||
|
pub fn unlock_gallery(username: &str, passphrase: &str) -> std::result::Result<(), String> {
|
||||||
|
use argon2::password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString};
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
if passphrase.is_empty() || passphrase.len() > 1024 {
|
||||||
|
return Err("Enter your Gallery passphrase.".into());
|
||||||
|
}
|
||||||
|
static VERIFY: parking_lot::Mutex<()> = parking_lot::Mutex::new(());
|
||||||
|
let _verify = VERIFY.lock();
|
||||||
|
let service = "io.narl.protongallery";
|
||||||
|
let user = format!("hidden-albums:{username}");
|
||||||
|
let argon = argon2::Argon2::default();
|
||||||
|
match with_keyring_entry(service, &user, Entry::get_password) {
|
||||||
|
Ok(stored) => {
|
||||||
|
let hash = PasswordHash::new(&stored)
|
||||||
|
.map_err(|_| "The saved Gallery passphrase is unreadable.")?;
|
||||||
|
argon
|
||||||
|
.verify_password(passphrase.as_bytes(), &hash)
|
||||||
|
.map_err(|_| "The Gallery passphrase is incorrect.".into())
|
||||||
|
}
|
||||||
|
Err(Error::Keyring(keyring_core::Error::NoEntry)) => {
|
||||||
|
if passphrase.chars().count() < 12 {
|
||||||
|
return Err("Choose a Gallery passphrase with at least 12 characters.".into());
|
||||||
|
}
|
||||||
|
let mut bytes = [0; 16];
|
||||||
|
std::fs::File::open("/dev/urandom")
|
||||||
|
.and_then(|mut file| file.read_exact(&mut bytes))
|
||||||
|
.map_err(|_| "Couldn’t generate the passphrase salt.")?;
|
||||||
|
let salt = SaltString::encode_b64(&bytes)
|
||||||
|
.map_err(|_| "Couldn’t generate the passphrase salt.")?;
|
||||||
|
let hash = argon
|
||||||
|
.hash_password(passphrase.as_bytes(), &salt)
|
||||||
|
.map_err(|_| "Couldn’t protect the Gallery passphrase.")?
|
||||||
|
.to_string();
|
||||||
|
with_keyring_entry(service, &user, |entry| entry.set_password(&hash))
|
||||||
|
.map_err(|_| "Couldn’t save the Gallery passphrase in the system keyring.".into())
|
||||||
|
}
|
||||||
|
Err(_) => Err("The system keyring is locked or unavailable.".into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Run `op` on the entry `service`/`user`, reconnecting once if the Secret
|
/// Run `op` on the entry `service`/`user`, reconnecting once if the Secret
|
||||||
/// Service fails the call.
|
/// Service fails the call.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -579,6 +579,7 @@ impl ContentCache {
|
|||||||
// the disk.
|
// the disk.
|
||||||
cache.reseed_totals();
|
cache.reseed_totals();
|
||||||
cache.import_legacy_pins()?;
|
cache.import_legacy_pins()?;
|
||||||
|
cache.set_budget(max_bytes);
|
||||||
Ok(cache)
|
Ok(cache)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,16 +1154,18 @@ impl ContentCache {
|
|||||||
};
|
};
|
||||||
let mut skipped = 0usize;
|
let mut skipped = 0usize;
|
||||||
while running > cap {
|
while running > cap {
|
||||||
// Fetch a batch past whatever we have already skipped as exempt.
|
// A whole batch can be pinned. Keep looking until the index has
|
||||||
let want = skipped + EVICT_BATCH;
|
// no entries past the ones we have skipped.
|
||||||
let Ok(batch) = self.db.cache_eviction_candidates(kind, want) else {
|
let Ok(batch) = self
|
||||||
|
.db
|
||||||
|
.cache_eviction_candidates(kind, EVICT_BATCH, skipped)
|
||||||
|
else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
if batch.len() <= skipped {
|
if batch.is_empty() {
|
||||||
break; // nothing new to consider
|
break;
|
||||||
}
|
}
|
||||||
let mut evicted_any = false;
|
for (key, size) in batch {
|
||||||
for (key, size) in batch.into_iter().skip(skipped) {
|
|
||||||
if running <= cap {
|
if running <= cap {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1170,14 +1173,18 @@ impl ContentCache {
|
|||||||
skipped += 1; // counts toward the total, never a victim
|
skipped += 1; // counts toward the total, never a victim
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let _ = std::fs::remove_file(dir.join(&key));
|
if let Err(error) = std::fs::remove_file(dir.join(&key))
|
||||||
|
&& error.kind() != std::io::ErrorKind::NotFound
|
||||||
|
{
|
||||||
|
skipped += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let _ = std::fs::remove_file(dir.join(format!("{key}.meta")));
|
let _ = std::fs::remove_file(dir.join(format!("{key}.meta")));
|
||||||
let _ = self.db.cache_remove(&key);
|
if self.db.cache_remove(&key).is_err() {
|
||||||
|
skipped += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
running = running.saturating_sub(size);
|
running = running.saturating_sub(size);
|
||||||
evicted_any = true;
|
|
||||||
}
|
|
||||||
if !evicted_any {
|
|
||||||
break; // every remaining candidate is exempt
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The index is the truth; realign the fast path with it.
|
// The index is the truth; realign the fast path with it.
|
||||||
@@ -1405,7 +1412,7 @@ impl ContentCache {
|
|||||||
.collect();
|
.collect();
|
||||||
let content_dir = self.content_dir.clone();
|
let content_dir = self.content_dir.clone();
|
||||||
// Force pool enforcement ignoring current cap check to free disk space immediately
|
// Force pool enforcement ignoring current cap check to free disk space immediately
|
||||||
let Ok(list) = self.db.cache_eviction_candidates(KIND_BLOB, 10) else {
|
let Ok(list) = self.db.cache_eviction_candidates(KIND_BLOB, 10, 0) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
for (key, bytes) in list {
|
for (key, bytes) in list {
|
||||||
@@ -1883,13 +1890,13 @@ impl ContentCache {
|
|||||||
// Pinned blobs (by cache key) are exempt from eviction. Resolves direct
|
// Pinned blobs (by cache key) are exempt from eviction. Resolves direct
|
||||||
// pins plus every descendant of a recursively-pinned folder, hashed into
|
// pins plus every descendant of a recursively-pinned folder, hashed into
|
||||||
// cache keys to match on-disk filenames.
|
// cache keys to match on-disk filenames.
|
||||||
let pinned: HashSet<String> = self
|
let pinned = match self.db.pinned_uids() {
|
||||||
.db
|
Ok(uids) => uids.iter().map(|uid| Self::key_str(uid)).collect(),
|
||||||
.pinned_uids()
|
Err(error) => {
|
||||||
.unwrap_or_default()
|
tracing::warn!(%error, "reading pins for cache eviction failed");
|
||||||
.iter()
|
return;
|
||||||
.map(|uid| Self::key_str(uid))
|
}
|
||||||
.collect();
|
};
|
||||||
let content_dir = self.content_dir.clone();
|
let content_dir = self.content_dir.clone();
|
||||||
self.enforce_pool(KIND_BLOB, &content_dir, Some(&pinned));
|
self.enforce_pool(KIND_BLOB, &content_dir, Some(&pinned));
|
||||||
}
|
}
|
||||||
@@ -2010,8 +2017,7 @@ impl ContentCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retune the soft byte cap (`0` = unlimited) at runtime and immediately
|
/// Retune the soft byte cap (`0` = unlimited) at runtime and immediately
|
||||||
/// enforce it: blobs and blocks are LRU-evicted back under the new cap (a
|
/// enforce it across all three pools.
|
||||||
/// lower cap frees space now; a higher one is a no-op until the next store).
|
|
||||||
/// Called by the daemon when the Settings page changes the cache budget.
|
/// Called by the daemon when the Settings page changes the cache budget.
|
||||||
pub fn set_budget(&self, bytes: u64) {
|
pub fn set_budget(&self, bytes: u64) {
|
||||||
self.max_bytes.store(bytes, Ordering::Relaxed);
|
self.max_bytes.store(bytes, Ordering::Relaxed);
|
||||||
@@ -2245,19 +2251,50 @@ mod tests {
|
|||||||
// crash) but the same on-disk cache: reconcile repopulates from disk.
|
// crash) but the same on-disk cache: reconcile repopulates from disk.
|
||||||
let db2 = Arc::new(Db::open_in_memory().unwrap());
|
let db2 = Arc::new(Db::open_in_memory().unwrap());
|
||||||
assert!(db2.cache_entries_by_kind("blob").unwrap().is_empty());
|
assert!(db2.cache_entries_by_kind("blob").unwrap().is_empty());
|
||||||
let c = ContentCache::open(content, pins, 8, db2.clone()).unwrap();
|
let c = ContentCache::open(content, pins, 0, db2.clone()).unwrap();
|
||||||
assert_eq!(db2.cache_entries_by_kind("blob").unwrap().len(), 3);
|
assert_eq!(db2.cache_entries_by_kind("blob").unwrap().len(), 3);
|
||||||
|
|
||||||
// With the index rebuilt, a further store enforces the budget against the
|
assert_eq!(c.usage(), 12);
|
||||||
// reconciled entries instead of leaking them.
|
}
|
||||||
c.store(&uid("d"), 1, 4, b"dddd").unwrap();
|
|
||||||
let total: u64 = db2
|
#[test]
|
||||||
.cache_entries_by_kind("blob")
|
fn reopening_trims_all_cache_pools_even_when_the_oldest_batch_is_pinned() {
|
||||||
.unwrap()
|
let (c, _dir) = cache();
|
||||||
.iter()
|
for i in 0..EVICT_BATCH {
|
||||||
.map(|(_, s)| s)
|
let u = uid(&format!("pinned-{i}"));
|
||||||
.sum();
|
c.store(&u, 1, 1, b"p").unwrap();
|
||||||
assert!(total <= 8, "budget enforced after reconcile, total={total}");
|
c.add_pin(&u, Path::new("pinned"), false).unwrap();
|
||||||
|
std::fs::File::open(c.blob_path(&u))
|
||||||
|
.unwrap()
|
||||||
|
.set_modified(UNIX_EPOCH)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
let unpinned = uid("unpinned");
|
||||||
|
let payload = [0u8; 64];
|
||||||
|
let size = payload.len() as u64;
|
||||||
|
c.store(&unpinned, 1, size, &payload).unwrap();
|
||||||
|
c.store_block(&unpinned, 1, size, blk(size, 0), &payload)
|
||||||
|
.unwrap();
|
||||||
|
c.store_thumbnail(&unpinned, 1, 1, &payload).unwrap();
|
||||||
|
let recovery = c.recovery_dir.join("recovered.bin");
|
||||||
|
std::fs::write(&recovery, b"recovered write").unwrap();
|
||||||
|
|
||||||
|
let budget = (EVICT_BATCH as u64 * 100).div_ceil(SPLIT_BLOB);
|
||||||
|
let reopened = ContentCache::open(
|
||||||
|
c.content_dir.clone(),
|
||||||
|
c.pins_path.clone(),
|
||||||
|
budget,
|
||||||
|
c.db.clone(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(reopened.usage(), EVICT_BATCH as u64);
|
||||||
|
assert!(!reopened.blob_path(&unpinned).exists());
|
||||||
|
for i in 0..EVICT_BATCH {
|
||||||
|
assert!(reopened.is_cached(&uid(&format!("pinned-{i}")), 1, 1));
|
||||||
|
}
|
||||||
|
assert_eq!(std::fs::read(recovery).unwrap(), b"recovered write");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An eviction removes the blob, then its tag. A crash in between, or a
|
/// An eviction removes the blob, then its tag. A crash in between, or a
|
||||||
|
|||||||
@@ -44,14 +44,20 @@ pub enum Request {
|
|||||||
/// Report mount status (account, mountpoint, pin count).
|
/// Report mount status (account, mountpoint, pin count).
|
||||||
Status,
|
Status,
|
||||||
/// Pin a file (path relative to the mountpoint, or absolute under it).
|
/// Pin a file (path relative to the mountpoint, or absolute under it).
|
||||||
Pin { path: String },
|
Pin {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// Unpin a file, evicting its cached content.
|
/// Unpin a file, evicting its cached content.
|
||||||
Unpin { path: String },
|
Unpin {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// List pinned files.
|
/// List pinned files.
|
||||||
ListPins,
|
ListPins,
|
||||||
/// List a directory for the in-app file browser. `path` is
|
/// List a directory for the in-app file browser. `path` is
|
||||||
/// mountpoint-relative (empty or "." = the mount root).
|
/// mountpoint-relative (empty or "." = the mount root).
|
||||||
ListDir { path: String },
|
ListDir {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// Fetch a page of the photos timeline, newest first. Returns metadata only:
|
/// Fetch a page of the photos timeline, newest first. Returns metadata only:
|
||||||
/// a thumbnail path comes back only for photos already in the cache, so the
|
/// a thumbnail path comes back only for photos already in the cache, so the
|
||||||
/// reply never waits on the network. Front-ends ask for the thumbnails they
|
/// reply never waits on the network. Front-ends ask for the thumbnails they
|
||||||
@@ -83,7 +89,9 @@ pub enum Request {
|
|||||||
/// live photo and its clip. Replies with [`Response::Photos`], holding one
|
/// live photo and its clip. Replies with [`Response::Photos`], holding one
|
||||||
/// item per file in server order; a photo that stands alone comes back as a
|
/// item per file in server order; a photo that stands alone comes back as a
|
||||||
/// single item. The lightbox uses it to switch between a shot's files.
|
/// single item. The lightbox uses it to switch between a shot's files.
|
||||||
PhotoGroup { uid: String },
|
PhotoGroup {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// The months the timeline spans (newest first, with per-month counts) so a
|
/// The months the timeline spans (newest first, with per-month counts) so a
|
||||||
/// front-end can build a date scrubber without paging the whole library.
|
/// front-end can build a date scrubber without paging the whole library.
|
||||||
/// `kind` scopes the counts to one tab when set.
|
/// `kind` scopes the counts to one tab when set.
|
||||||
@@ -94,7 +102,9 @@ pub enum Request {
|
|||||||
/// Photos taken on today's date in earlier years, newest first, at most
|
/// Photos taken on today's date in earlier years, newest first, at most
|
||||||
/// `limit` of them — the "On this day" strip above the timeline. Replies
|
/// `limit` of them — the "On this day" strip above the timeline. Replies
|
||||||
/// with [`Response::Photos`]; a front-end groups them by year itself.
|
/// with [`Response::Photos`]; a front-end groups them by year itself.
|
||||||
PhotosOnThisDay { limit: usize },
|
PhotosOnThisDay {
|
||||||
|
limit: usize,
|
||||||
|
},
|
||||||
/// Sets of photos that are byte-identical copies of each other, going by
|
/// Sets of photos that are byte-identical copies of each other, going by
|
||||||
/// the server's content hash. Replies with [`Response::PhotoDuplicates`].
|
/// the server's content hash. Replies with [`Response::PhotoDuplicates`].
|
||||||
PhotoDuplicates,
|
PhotoDuplicates,
|
||||||
@@ -118,7 +128,9 @@ pub enum Request {
|
|||||||
},
|
},
|
||||||
/// Every photo taken in one town with where exactly it was taken, for the
|
/// Every photo taken in one town with where exactly it was taken, for the
|
||||||
/// map's close-up. Replies with [`Response::PhotoLocations`].
|
/// map's close-up. Replies with [`Response::PhotoLocations`].
|
||||||
PlaceLocations { id: u32 },
|
PlaceLocations {
|
||||||
|
id: u32,
|
||||||
|
},
|
||||||
/// List the account's photo albums, newest activity first, including the
|
/// List the account's photo albums, newest activity first, including the
|
||||||
/// albums other people share with us. Metadata only — an album's cover
|
/// albums other people share with us. Metadata only — an album's cover
|
||||||
/// thumbnail is fetched with [`Request::PhotoThumbs`] like any other photo.
|
/// thumbnail is fetched with [`Request::PhotoThumbs`] like any other photo.
|
||||||
@@ -134,9 +146,14 @@ pub enum Request {
|
|||||||
limit: usize,
|
limit: usize,
|
||||||
},
|
},
|
||||||
/// Create an album named `name`. Replies with [`Response::AlbumCreated`].
|
/// Create an album named `name`. Replies with [`Response::AlbumCreated`].
|
||||||
CreateAlbum { name: String },
|
CreateAlbum {
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
/// Rename the album `uid`. Replies with [`Response::Ok`].
|
/// Rename the album `uid`. Replies with [`Response::Ok`].
|
||||||
RenameAlbum { uid: String, name: String },
|
RenameAlbum {
|
||||||
|
uid: String,
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
/// Delete the album `uid`. Its photos stay in the timeline; with
|
/// Delete the album `uid`. Its photos stay in the timeline; with
|
||||||
/// `delete_photos` set, photos that exist only in the album (saved from a
|
/// `delete_photos` set, photos that exist only in the album (saved from a
|
||||||
/// shared album) are deleted with it, which the server otherwise refuses.
|
/// shared album) are deleted with it, which the server otherwise refuses.
|
||||||
@@ -148,14 +165,22 @@ pub enum Request {
|
|||||||
},
|
},
|
||||||
/// Add timeline photos to the album `uid`. Replies with
|
/// Add timeline photos to the album `uid`. Replies with
|
||||||
/// [`Response::AlbumChanged`].
|
/// [`Response::AlbumChanged`].
|
||||||
AddToAlbum { uid: String, photos: Vec<String> },
|
AddToAlbum {
|
||||||
|
uid: String,
|
||||||
|
photos: Vec<String>,
|
||||||
|
},
|
||||||
/// Take photos out of the album `uid`. They stay in the timeline: this is
|
/// Take photos out of the album `uid`. They stay in the timeline: this is
|
||||||
/// not a trash. Replies with [`Response::AlbumChanged`].
|
/// not a trash. Replies with [`Response::AlbumChanged`].
|
||||||
RemoveFromAlbum { uid: String, photos: Vec<String> },
|
RemoveFromAlbum {
|
||||||
|
uid: String,
|
||||||
|
photos: Vec<String>,
|
||||||
|
},
|
||||||
/// Fetch thumbnails for the given photo uids, downloading the ones not
|
/// Fetch thumbnails for the given photo uids, downloading the ones not
|
||||||
/// already cached (one batched round-trip) and replying with their on-disk
|
/// already cached (one batched round-trip) and replying with their on-disk
|
||||||
/// paths. Keep the batch small — it is served on demand, as tiles scroll in.
|
/// paths. Keep the batch small — it is served on demand, as tiles scroll in.
|
||||||
PhotoThumbs { uids: Vec<String> },
|
PhotoThumbs {
|
||||||
|
uids: Vec<String>,
|
||||||
|
},
|
||||||
/// Trash photos by node uid, answered with [`Response::Trashed`].
|
/// Trash photos by node uid, answered with [`Response::Trashed`].
|
||||||
///
|
///
|
||||||
/// Uid-addressed rather than path-addressed because the photos volume is not
|
/// Uid-addressed rather than path-addressed because the photos volume is not
|
||||||
@@ -190,11 +215,15 @@ pub enum Request {
|
|||||||
ReserveFileThumbGeneration,
|
ReserveFileThumbGeneration,
|
||||||
/// Stop ordinary-file thumbnail work belonging to older listings. Photos
|
/// Stop ordinary-file thumbnail work belonging to older listings. Photos
|
||||||
/// timeline work and an explicit recursive build are deliberately separate.
|
/// timeline work and an explicit recursive build are deliberately separate.
|
||||||
CancelFileThumbs { generation: u64 },
|
CancelFileThumbs {
|
||||||
|
generation: u64,
|
||||||
|
},
|
||||||
/// Start building local thumbnails for every supported image below `path`.
|
/// Start building local thumbnails for every supported image below `path`.
|
||||||
/// The request returns immediately; progress is read with
|
/// The request returns immediately; progress is read with
|
||||||
/// [`Request::ThumbnailBuildStatus`].
|
/// [`Request::ThumbnailBuildStatus`].
|
||||||
StartThumbnailBuild { path: String },
|
StartThumbnailBuild {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// Stop the current recursive ordinary-file thumbnail build, if any.
|
/// Stop the current recursive ordinary-file thumbnail build, if any.
|
||||||
CancelThumbnailBuild,
|
CancelThumbnailBuild,
|
||||||
/// Read progress for the recursive ordinary-file thumbnail build.
|
/// Read progress for the recursive ordinary-file thumbnail build.
|
||||||
@@ -206,7 +235,25 @@ pub enum Request {
|
|||||||
/// is how a front-end knows when the refreshed timeline is worth re-reading.
|
/// is how a front-end knows when the refreshed timeline is worth re-reading.
|
||||||
PhotosRefreshStatus,
|
PhotosRefreshStatus,
|
||||||
/// Download a photo's full content into the cache; replies with its path.
|
/// Download a photo's full content into the cache; replies with its path.
|
||||||
OpenPhoto { uid: String },
|
OpenPhoto {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
/// Open a revision for playback in the local viewer.
|
||||||
|
OpenGalleryVideo {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
OpenGalleryImage {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
CloseGalleryVideo {
|
||||||
|
token: String,
|
||||||
|
},
|
||||||
|
GalleryThumbnail {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
DriveGallery {
|
||||||
|
action: GalleryAction,
|
||||||
|
},
|
||||||
/// Add or remove Proton's `Favorite` tag on a photo. Replies with
|
/// Add or remove Proton's `Favorite` tag on a photo. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
///
|
///
|
||||||
@@ -214,7 +261,10 @@ pub enum Request {
|
|||||||
/// one shared with us, or one that lives only in an album — needs it
|
/// one shared with us, or one that lives only in an album — needs it
|
||||||
/// re-encrypted for our timeline, which the SDK does not implement yet; the
|
/// re-encrypted for our timeline, which the SDK does not implement yet; the
|
||||||
/// daemon reports that as an error rather than silently doing nothing.
|
/// daemon reports that as an error rather than silently doing nothing.
|
||||||
SetPhotoFavorite { uid: String, favorite: bool },
|
SetPhotoFavorite {
|
||||||
|
uid: String,
|
||||||
|
favorite: bool,
|
||||||
|
},
|
||||||
/// Import Google Photos **Takeout** archives into Proton Photos.
|
/// Import Google Photos **Takeout** archives into Proton Photos.
|
||||||
///
|
///
|
||||||
/// `archives` are absolute paths to the export's `.zip` parts on the
|
/// `archives` are absolute paths to the export's `.zip` parts on the
|
||||||
@@ -326,7 +376,10 @@ pub enum Request {
|
|||||||
/// Search the daemon's index of *local* (non-Drive) files on this machine.
|
/// Search the daemon's index of *local* (non-Drive) files on this machine.
|
||||||
/// Independent of [`Request::Search`] so a front-end can fire both at once and
|
/// Independent of [`Request::Search`] so a front-end can fire both at once and
|
||||||
/// render whichever lands first. Replies with [`Response::LocalResults`].
|
/// render whichever lands first. Replies with [`Response::LocalResults`].
|
||||||
SearchLocal { query: String, limit: usize },
|
SearchLocal {
|
||||||
|
query: String,
|
||||||
|
limit: usize,
|
||||||
|
},
|
||||||
/// Search both the Drive metadata index and the local-file index in one
|
/// Search both the Drive metadata index and the local-file index in one
|
||||||
/// round-trip. This is the preferred prompt API; the two legacy search
|
/// round-trip. This is the preferred prompt API; the two legacy search
|
||||||
/// requests remain available for older clients. `limit` applies to each
|
/// requests remain available for older clients. `limit` applies to each
|
||||||
@@ -342,30 +395,48 @@ pub enum Request {
|
|||||||
},
|
},
|
||||||
/// Rename a file or folder. `path` is mountpoint-relative; `new_name` is a
|
/// Rename a file or folder. `path` is mountpoint-relative; `new_name` is a
|
||||||
/// single path component (no separators). Replies with [`Response::Ok`].
|
/// single path component (no separators). Replies with [`Response::Ok`].
|
||||||
Rename { path: String, new_name: String },
|
Rename {
|
||||||
|
path: String,
|
||||||
|
new_name: String,
|
||||||
|
},
|
||||||
/// Move a file or folder into a new parent folder. Both `path` and
|
/// Move a file or folder into a new parent folder. Both `path` and
|
||||||
/// `new_parent` are mountpoint-relative, or both absolute local paths; two
|
/// `new_parent` are mountpoint-relative, or both absolute local paths; two
|
||||||
/// absolute paths may lie in different locations (My files, an on-demand
|
/// absolute paths may lie in different locations (My files, an on-demand
|
||||||
/// or a mirror synced folder), and the move is still made on Proton Drive
|
/// or a mirror synced folder), and the move is still made on Proton Drive
|
||||||
/// without transferring content. Replies with [`Response::Ok`].
|
/// without transferring content. Replies with [`Response::Ok`].
|
||||||
Move { path: String, new_parent: String },
|
Move {
|
||||||
|
path: String,
|
||||||
|
new_parent: String,
|
||||||
|
},
|
||||||
/// Copy a file or folder into a folder on Proton Drive, without
|
/// Copy a file or folder into a folder on Proton Drive, without
|
||||||
/// downloading or uploading it. Both `path` and `new_parent` are
|
/// downloading or uploading it. Both `path` and `new_parent` are
|
||||||
/// mountpoint-relative, or absolute paths inside My files. A name already
|
/// mountpoint-relative, or absolute paths inside My files. A name already
|
||||||
/// taken in `new_parent` gets the next free ` (n)` suffix. Replies with
|
/// taken in `new_parent` gets the next free ` (n)` suffix. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
Copy { path: String, new_parent: String },
|
Copy {
|
||||||
|
path: String,
|
||||||
|
new_parent: String,
|
||||||
|
},
|
||||||
/// Ask Proton Drive how much the folder at mountpoint-relative `path`
|
/// Ask Proton Drive how much the folder at mountpoint-relative `path`
|
||||||
/// holds. Replies with [`Response::FolderSize`].
|
/// holds. Replies with [`Response::FolderSize`].
|
||||||
FolderSize { path: String },
|
FolderSize {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// The by-uid twin of [`Request::FolderSize`].
|
/// The by-uid twin of [`Request::FolderSize`].
|
||||||
FolderSizeByUid { uid: String },
|
FolderSizeByUid {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// Trash a file or folder. `path` is mountpoint-relative. Replies with
|
/// Trash a file or folder. `path` is mountpoint-relative. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
Delete { path: String },
|
Delete {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// Create a new folder named `name` under the mountpoint-relative `parent`.
|
/// Create a new folder named `name` under the mountpoint-relative `parent`.
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
CreateFolder { parent: String, name: String },
|
CreateFolder {
|
||||||
|
parent: String,
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
// There is deliberately no bytes-carrying single-file upload: it was
|
// There is deliberately no bytes-carrying single-file upload: it was
|
||||||
// `UploadFile { parent, name, bytes }`, and it OOMed on anything large for
|
// `UploadFile { parent, name, bytes }`, and it OOMed on anything large for
|
||||||
// the reason described on `UploadPhoto`. `UploadPaths` covers the same case
|
// the reason described on `UploadPhoto`. `UploadPaths` covers the same case
|
||||||
@@ -388,11 +459,16 @@ pub enum Request {
|
|||||||
/// Retune the on-disk cache's soft byte cap at runtime (`0` = unlimited) and
|
/// Retune the on-disk cache's soft byte cap at runtime (`0` = unlimited) and
|
||||||
/// persist it to config so the next mount keeps it. Replies with
|
/// persist it to config so the next mount keeps it. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
SetCacheBudget { bytes: u64 },
|
SetCacheBudget {
|
||||||
|
bytes: u64,
|
||||||
|
},
|
||||||
/// Cap uploads and downloads at these bytes per second (`0` = no cap),
|
/// Cap uploads and downloads at these bytes per second (`0` = no cap),
|
||||||
/// live for running transfers, and persist both to config so the next
|
/// live for running transfers, and persist both to config so the next
|
||||||
/// mount keeps them. Replies with [`Response::Ok`].
|
/// mount keeps them. Replies with [`Response::Ok`].
|
||||||
SetBandwidthLimits { upload: u64, download: u64 },
|
SetBandwidthLimits {
|
||||||
|
upload: u64,
|
||||||
|
download: u64,
|
||||||
|
},
|
||||||
/// Report on the health of the metadata database and content cache: sizes,
|
/// Report on the health of the metadata database and content cache: sizes,
|
||||||
/// row counts, and — when `deep` — SQLite's own integrity check. Replies
|
/// row counts, and — when `deep` — SQLite's own integrity check. Replies
|
||||||
/// with [`Response::CacheReport`].
|
/// with [`Response::CacheReport`].
|
||||||
@@ -429,10 +505,14 @@ pub enum Request {
|
|||||||
ListTrash,
|
ListTrash,
|
||||||
/// Restore trashed nodes, by uid, to the folders they were trashed from.
|
/// Restore trashed nodes, by uid, to the folders they were trashed from.
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
Restore { uids: Vec<String> },
|
Restore {
|
||||||
|
uids: Vec<String>,
|
||||||
|
},
|
||||||
/// Permanently delete trashed nodes by uid. Irreversible: the content is
|
/// Permanently delete trashed nodes by uid. Irreversible: the content is
|
||||||
/// gone from Proton Drive, not moved. Replies with [`Response::Ok`].
|
/// gone from Proton Drive, not moved. Replies with [`Response::Ok`].
|
||||||
DeleteForever { uids: Vec<String> },
|
DeleteForever {
|
||||||
|
uids: Vec<String>,
|
||||||
|
},
|
||||||
/// Permanently delete everything in the trash. Irreversible.
|
/// Permanently delete everything in the trash. Irreversible.
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
EmptyTrash,
|
EmptyTrash,
|
||||||
@@ -443,7 +523,9 @@ pub enum Request {
|
|||||||
/// only notices another client's changes when its TTL lapses, so a user who
|
/// only notices another client's changes when its TTL lapses, so a user who
|
||||||
/// knows the cache is stale needs a way to say so. Cheap and idempotent —
|
/// knows the cache is stale needs a way to say so. Cheap and idempotent —
|
||||||
/// it invalidates, it does not fetch.
|
/// it invalidates, it does not fetch.
|
||||||
Refresh { scope: RefreshScope },
|
Refresh {
|
||||||
|
scope: RefreshScope,
|
||||||
|
},
|
||||||
|
|
||||||
// ---- locations --------------------------------------------------------
|
// ---- locations --------------------------------------------------------
|
||||||
/// List every local Proton Drive location. Replies with
|
/// List every local Proton Drive location. Replies with
|
||||||
@@ -454,26 +536,37 @@ pub enum Request {
|
|||||||
/// List the account's registered devices. Replies with [`Response::Devices`].
|
/// List the account's registered devices. Replies with [`Response::Devices`].
|
||||||
ListDevices,
|
ListDevices,
|
||||||
/// Rename a device by its uid. Replies with [`Response::Ok`].
|
/// Rename a device by its uid. Replies with [`Response::Ok`].
|
||||||
RenameDevice { uid: String, name: String },
|
RenameDevice {
|
||||||
|
uid: String,
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
/// Delete (deregister) a device by its uid. Replies with [`Response::Ok`].
|
/// Delete (deregister) a device by its uid. Replies with [`Response::Ok`].
|
||||||
DeleteDevice { uid: String },
|
DeleteDevice {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// Adopt an existing device as this machine's, pinning its uid in
|
/// Adopt an existing device as this machine's, pinning its uid in
|
||||||
/// `config.json` so a hostname change or reinstall re-attaches to it instead
|
/// `config.json` so a hostname change or reinstall re-attaches to it instead
|
||||||
/// of registering a duplicate. `uid: None` clears the pin.
|
/// of registering a duplicate. `uid: None` clears the pin.
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
AdoptDevice { uid: Option<String> },
|
AdoptDevice {
|
||||||
|
uid: Option<String>,
|
||||||
|
},
|
||||||
/// Move every folder another device backs up into this machine's own
|
/// Move every folder another device backs up into this machine's own
|
||||||
/// device, as server-side moves on the main volume. The other device stays
|
/// device, as server-side moves on the main volume. The other device stays
|
||||||
/// registered, without those folders. Sync folders here that already track
|
/// registered, without those folders. Sync folders here that already track
|
||||||
/// one of them follow it to its new share. Nothing is downloaded: the moved
|
/// one of them follow it to its new share. Nothing is downloaded: the moved
|
||||||
/// folders are then offered by [`Request::ListRestorableFolders`].
|
/// folders are then offered by [`Request::ListRestorableFolders`].
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
MigrateDevice { uid: String },
|
MigrateDevice {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
|
||||||
// ---- device folder sync ----------------------------------
|
// ---- device folder sync ----------------------------------
|
||||||
/// Add a local folder to this machine's device, uploading its tree and
|
/// Add a local folder to this machine's device, uploading its tree and
|
||||||
/// registering the device on first use. Replies with [`Response::Ok`].
|
/// registering the device on first use. Replies with [`Response::Ok`].
|
||||||
AddSyncFolder { local_path: String },
|
AddSyncFolder {
|
||||||
|
local_path: String,
|
||||||
|
},
|
||||||
/// Keep a real local directory in step with an existing folder in My files.
|
/// Keep a real local directory in step with an existing folder in My files.
|
||||||
/// First sync unions one-sided files and preserves differing versions.
|
/// First sync unions one-sided files and preserves differing versions.
|
||||||
/// Replies with [`Response::Ok`]; no device backup is created.
|
/// Replies with [`Response::Ok`]; no device backup is created.
|
||||||
@@ -485,42 +578,65 @@ pub enum Request {
|
|||||||
ListSyncFolders,
|
ListSyncFolders,
|
||||||
/// Remove a synced folder by id; `delete_remote` also trashes its cloud copy.
|
/// Remove a synced folder by id; `delete_remote` also trashes its cloud copy.
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
RemoveSyncFolder { id: i64, delete_remote: bool },
|
RemoveSyncFolder {
|
||||||
|
id: i64,
|
||||||
|
delete_remote: bool,
|
||||||
|
},
|
||||||
/// Switch a synced folder between `mirror` and `ondemand` (Phase 3). Replies
|
/// Switch a synced folder between `mirror` and `ondemand` (Phase 3). Replies
|
||||||
/// with [`Response::Ok`].
|
/// with [`Response::Ok`].
|
||||||
SetSyncFolderMode { id: i64, mode: String },
|
SetSyncFolderMode {
|
||||||
|
id: i64,
|
||||||
|
mode: String,
|
||||||
|
},
|
||||||
/// Pause or resume one mirror folder's reconcile, independent of the
|
/// Pause or resume one mirror folder's reconcile, independent of the
|
||||||
/// global pause. Persisted until resumed. Replies with [`Response::Ok`].
|
/// global pause. Persisted until resumed. Replies with [`Response::Ok`].
|
||||||
SetSyncFolderPaused { id: i64, paused: bool },
|
SetSyncFolderPaused {
|
||||||
|
id: i64,
|
||||||
|
paused: bool,
|
||||||
|
},
|
||||||
/// Forget what a mirror folder synced before, so its next pass compares
|
/// Forget what a mirror folder synced before, so its next pass compares
|
||||||
/// both sides afresh: what is on one side only is copied to the other, and
|
/// both sides afresh: what is on one side only is copied to the other, and
|
||||||
/// a file that differs keeps both versions. Nothing is deleted. Replies
|
/// a file that differs keeps both versions. Nothing is deleted. Replies
|
||||||
/// with [`Response::Ok`].
|
/// with [`Response::Ok`].
|
||||||
ResetSyncFolder { id: i64 },
|
ResetSyncFolder {
|
||||||
|
id: i64,
|
||||||
|
},
|
||||||
/// Force a reconcile pass: one folder by id, or all when `id` is `None`.
|
/// Force a reconcile pass: one folder by id, or all when `id` is `None`.
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
SyncNow { id: Option<i64> },
|
SyncNow {
|
||||||
|
id: Option<i64>,
|
||||||
|
},
|
||||||
/// Pause or resume syncing: queued uploads and changes stop draining and
|
/// Pause or resume syncing: queued uploads and changes stop draining and
|
||||||
/// mirror folders stop reconciling, while reads through the mount keep
|
/// mirror folders stop reconciling, while reads through the mount keep
|
||||||
/// working. `until` is the Unix second a pause ends by itself; `None`
|
/// working. `until` is the Unix second a pause ends by itself; `None`
|
||||||
/// pauses until resumed. Ignored when resuming. Replies with
|
/// pauses until resumed. Ignored when resuming. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
SetSyncPaused { paused: bool, until: Option<i64> },
|
SetSyncPaused {
|
||||||
|
paused: bool,
|
||||||
|
until: Option<i64>,
|
||||||
|
},
|
||||||
/// List the queue of uploads and changes not yet on the remote. Replies
|
/// List the queue of uploads and changes not yet on the remote. Replies
|
||||||
/// with [`Response::PendingOps`].
|
/// with [`Response::PendingOps`].
|
||||||
ListPendingOps,
|
ListPendingOps,
|
||||||
/// Retry a backed-off queued op now instead of waiting out its backoff;
|
/// Retry a backed-off queued op now instead of waiting out its backoff;
|
||||||
/// every failed op when `id` is `None`. Replies with [`Response::Ok`].
|
/// every failed op when `id` is `None`. Replies with [`Response::Ok`].
|
||||||
RetryPendingOp { id: Option<i64> },
|
RetryPendingOp {
|
||||||
|
id: Option<i64>,
|
||||||
|
},
|
||||||
/// Copy the content of a queued upload (`id` from
|
/// Copy the content of a queued upload (`id` from
|
||||||
/// [`Request::ListPendingOps`]) to `dest`, an absolute path that must not
|
/// [`Request::ListPendingOps`]) to `dest`, an absolute path that must not
|
||||||
/// exist yet. The op stays queued. Replies with [`Response::Ok`].
|
/// exist yet. The op stays queued. Replies with [`Response::Ok`].
|
||||||
ExportPendingOp { id: i64, dest: String },
|
ExportPendingOp {
|
||||||
|
id: i64,
|
||||||
|
dest: String,
|
||||||
|
},
|
||||||
/// Drop a queued change (`id` from [`Request::ListPendingOps`]) and undo
|
/// Drop a queued change (`id` from [`Request::ListPendingOps`]) and undo
|
||||||
/// it locally: a node made here goes, a node Drive has goes back to what
|
/// it locally: a node made here goes, a node Drive has goes back to what
|
||||||
/// Drive has, along with every other change queued on it. Its content is
|
/// Drive has, along with every other change queued on it. Its content is
|
||||||
/// lost unless it was exported first. Replies with [`Response::Ok`].
|
/// lost unless it was exported first. Replies with [`Response::Ok`].
|
||||||
DiscardPendingOp { id: i64 },
|
DiscardPendingOp {
|
||||||
|
id: i64,
|
||||||
|
},
|
||||||
/// List the `(sync-conflict …)` copies under My Files and in synced
|
/// List the `(sync-conflict …)` copies under My Files and in synced
|
||||||
/// folders. Replies with
|
/// folders. Replies with
|
||||||
/// [`Response::Conflicts`].
|
/// [`Response::Conflicts`].
|
||||||
@@ -529,18 +645,25 @@ pub enum Request {
|
|||||||
/// copy in a synced folder).
|
/// copy in a synced folder).
|
||||||
/// Everything removed goes to the Proton trash. Replies with
|
/// Everything removed goes to the Proton trash. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
ResolveConflict { path: String, keep: ConflictKeep },
|
ResolveConflict {
|
||||||
|
path: String,
|
||||||
|
keep: ConflictKeep,
|
||||||
|
},
|
||||||
/// List the folders under this machine's device that can be synced here,
|
/// List the folders under this machine's device that can be synced here,
|
||||||
/// each with a proposed local path. Replies with
|
/// each with a proposed local path. Replies with
|
||||||
/// [`Response::RestorableFolders`].
|
/// [`Response::RestorableFolders`].
|
||||||
ListRestorableFolders,
|
ListRestorableFolders,
|
||||||
/// Attach the given remote device folders to local paths and sync them down.
|
/// Attach the given remote device folders to local paths and sync them down.
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
RestoreSyncFolders { items: Vec<RestoreItem> },
|
RestoreSyncFolders {
|
||||||
|
items: Vec<RestoreItem>,
|
||||||
|
},
|
||||||
/// [`Request::ListRestorableFolders`] for another registered device, by
|
/// [`Request::ListRestorableFolders`] for another registered device, by
|
||||||
/// uid, so its folders can be synced down to this machine. Replies with
|
/// uid, so its folders can be synced down to this machine. Replies with
|
||||||
/// [`Response::RestorableFolders`].
|
/// [`Response::RestorableFolders`].
|
||||||
ListDeviceRestorableFolders { device: String },
|
ListDeviceRestorableFolders {
|
||||||
|
device: String,
|
||||||
|
},
|
||||||
/// [`Request::RestoreSyncFolders`] for folders under another device. A
|
/// [`Request::RestoreSyncFolders`] for folders under another device. A
|
||||||
/// separate variant rather than an optional field: an older daemon that
|
/// separate variant rather than an optional field: an older daemon that
|
||||||
/// ignored the field would attach the folders under this machine's device
|
/// ignored the field would attach the folders under this machine's device
|
||||||
@@ -571,9 +694,13 @@ pub enum Request {
|
|||||||
},
|
},
|
||||||
/// List the members, pending invitations and public link of the node at
|
/// List the members, pending invitations and public link of the node at
|
||||||
/// mountpoint-relative `path`. Replies with [`Response::Share`].
|
/// mountpoint-relative `path`. Replies with [`Response::Share`].
|
||||||
ListShare { path: String },
|
ListShare {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// The by-uid twin of [`Request::ListShare`].
|
/// The by-uid twin of [`Request::ListShare`].
|
||||||
ListShareByUid { uid: String },
|
ListShareByUid {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// Change the role of a share entry (member or pending invitation) on the node
|
/// Change the role of a share entry (member or pending invitation) on the node
|
||||||
/// at `path`. `id` and `kind` identify the entry (from [`Response::Share`]).
|
/// at `path`. `id` and `kind` identify the entry (from [`Response::Share`]).
|
||||||
/// Replies with [`Response::Ok`].
|
/// Replies with [`Response::Ok`].
|
||||||
@@ -621,9 +748,15 @@ pub enum Request {
|
|||||||
},
|
},
|
||||||
/// Remove the public link `id` from the node at `path`. Replies with
|
/// Remove the public link `id` from the node at `path`. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
RemovePublicLink { path: String, id: String },
|
RemovePublicLink {
|
||||||
|
path: String,
|
||||||
|
id: String,
|
||||||
|
},
|
||||||
/// The by-uid twin of [`Request::RemovePublicLink`].
|
/// The by-uid twin of [`Request::RemovePublicLink`].
|
||||||
RemovePublicLinkByUid { uid: String, id: String },
|
RemovePublicLinkByUid {
|
||||||
|
uid: String,
|
||||||
|
id: String,
|
||||||
|
},
|
||||||
/// Change the public link `id` on the node at `path`, keeping its URL.
|
/// Change the public link `id` on the node at `path`, keeping its URL.
|
||||||
/// `role` is "viewer" or "editor", or `None` to keep the current one.
|
/// `role` is "viewer" or "editor", or `None` to keep the current one.
|
||||||
/// Replies with [`Response::PublicLink`].
|
/// Replies with [`Response::PublicLink`].
|
||||||
@@ -646,28 +779,48 @@ pub enum Request {
|
|||||||
/// invitation and every member. Each removal is attempted even if an
|
/// invitation and every member. Each removal is attempted even if an
|
||||||
/// earlier one fails. Replies with [`Response::Ok`], or an error naming
|
/// earlier one fails. Replies with [`Response::Ok`], or an error naming
|
||||||
/// what is still shared.
|
/// what is still shared.
|
||||||
StopSharing { path: String },
|
StopSharing {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// The by-uid twin of [`Request::StopSharing`].
|
/// The by-uid twin of [`Request::StopSharing`].
|
||||||
StopSharingByUid { uid: String },
|
StopSharingByUid {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
|
||||||
// ---- revisions --------------------------------------------------------
|
// ---- revisions --------------------------------------------------------
|
||||||
/// List the version history of the file at mountpoint-relative `path`,
|
/// List the version history of the file at mountpoint-relative `path`,
|
||||||
/// newest first. Replies with [`Response::Revisions`].
|
/// newest first. Replies with [`Response::Revisions`].
|
||||||
ListRevisions { path: String },
|
ListRevisions {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// The by-uid twin of [`Request::ListRevisions`].
|
/// The by-uid twin of [`Request::ListRevisions`].
|
||||||
ListRevisionsByUid { uid: String },
|
ListRevisionsByUid {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// Make revision `revision_id` of the file at `path` current again. The
|
/// Make revision `revision_id` of the file at `path` current again. The
|
||||||
/// server applies this asynchronously, so the restored content may take a
|
/// server applies this asynchronously, so the restored content may take a
|
||||||
/// moment to appear. Replies with [`Response::Ok`].
|
/// moment to appear. Replies with [`Response::Ok`].
|
||||||
RestoreRevision { path: String, revision_id: String },
|
RestoreRevision {
|
||||||
|
path: String,
|
||||||
|
revision_id: String,
|
||||||
|
},
|
||||||
/// The by-uid twin of [`Request::RestoreRevision`].
|
/// The by-uid twin of [`Request::RestoreRevision`].
|
||||||
RestoreRevisionByUid { uid: String, revision_id: String },
|
RestoreRevisionByUid {
|
||||||
|
uid: String,
|
||||||
|
revision_id: String,
|
||||||
|
},
|
||||||
/// Permanently delete revision `revision_id` of the file at `path`. The
|
/// Permanently delete revision `revision_id` of the file at `path`. The
|
||||||
/// content is unrecoverable, and the server refuses to delete the revision
|
/// content is unrecoverable, and the server refuses to delete the revision
|
||||||
/// that is currently active. Replies with [`Response::Ok`].
|
/// that is currently active. Replies with [`Response::Ok`].
|
||||||
DeleteRevision { path: String, revision_id: String },
|
DeleteRevision {
|
||||||
|
path: String,
|
||||||
|
revision_id: String,
|
||||||
|
},
|
||||||
/// The by-uid twin of [`Request::DeleteRevision`].
|
/// The by-uid twin of [`Request::DeleteRevision`].
|
||||||
DeleteRevisionByUid { uid: String, revision_id: String },
|
DeleteRevisionByUid {
|
||||||
|
uid: String,
|
||||||
|
revision_id: String,
|
||||||
|
},
|
||||||
/// Write revision `revision_id` of the file at `path` to the absolute local
|
/// Write revision `revision_id` of the file at `path` to the absolute local
|
||||||
/// path `dest`, leaving the file's current content untouched. Replies with
|
/// path `dest`, leaving the file's current content untouched. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
@@ -699,15 +852,21 @@ pub enum Request {
|
|||||||
/// with [`Response::Entries`]; like [`Request::ListSharedWithMe`] the entries
|
/// with [`Response::Entries`]; like [`Request::ListSharedWithMe`] the entries
|
||||||
/// carry a `uid` and an empty `path`, since the subtree lives outside the
|
/// carry a `uid` and an empty `path`, since the subtree lives outside the
|
||||||
/// mount. Lets a front-end browse into a shared folder.
|
/// mount. Lets a front-end browse into a shared folder.
|
||||||
ListSharedFolder { uid: String },
|
ListSharedFolder {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// Download a file shared with me into the content cache, addressed by `uid`.
|
/// Download a file shared with me into the content cache, addressed by `uid`.
|
||||||
/// Replies with [`Response::FilePath`] so the front-end can open it with the
|
/// Replies with [`Response::FilePath`] so the front-end can open it with the
|
||||||
/// default app. The by-uid twin of [`Request::OpenFile`], which can only
|
/// default app. The by-uid twin of [`Request::OpenFile`], which can only
|
||||||
/// address nodes inside the mount.
|
/// address nodes inside the mount.
|
||||||
OpenSharedFile { uid: String },
|
OpenSharedFile {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// Leave a shared node by its `uid`, giving up my access. Replies with
|
/// Leave a shared node by its `uid`, giving up my access. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
LeaveShared { uid: String },
|
LeaveShared {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
|
||||||
// ---- incoming invitations ---------------------------------------------
|
// ---- incoming invitations ---------------------------------------------
|
||||||
/// List invitations addressed to me, pending accept or reject. Replies with
|
/// List invitations addressed to me, pending accept or reject. Replies with
|
||||||
@@ -715,9 +874,13 @@ pub enum Request {
|
|||||||
ListInvitations,
|
ListInvitations,
|
||||||
/// Accept the invitation `id`, gaining access to the shared node. Replies with
|
/// Accept the invitation `id`, gaining access to the shared node. Replies with
|
||||||
/// [`Response::Ok`].
|
/// [`Response::Ok`].
|
||||||
AcceptInvitation { id: String },
|
AcceptInvitation {
|
||||||
|
id: String,
|
||||||
|
},
|
||||||
/// Reject the invitation `id`, declining access. Replies with [`Response::Ok`].
|
/// Reject the invitation `id`, declining access. Replies with [`Response::Ok`].
|
||||||
RejectInvitation { id: String },
|
RejectInvitation {
|
||||||
|
id: String,
|
||||||
|
},
|
||||||
|
|
||||||
// ---- bookmarks --------------------------------------------------------
|
// ---- bookmarks --------------------------------------------------------
|
||||||
/// List public links saved to my account. Replies with [`Response::Bookmarks`].
|
/// List public links saved to my account. Replies with [`Response::Bookmarks`].
|
||||||
@@ -729,7 +892,9 @@ pub enum Request {
|
|||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
},
|
},
|
||||||
/// Remove a saved bookmark by its `token`. Replies with [`Response::Ok`].
|
/// Remove a saved bookmark by its `token`. Replies with [`Response::Ok`].
|
||||||
DeleteBookmark { token: String },
|
DeleteBookmark {
|
||||||
|
token: String,
|
||||||
|
},
|
||||||
|
|
||||||
// ---- account ----------------------------------------------------------
|
// ---- account ----------------------------------------------------------
|
||||||
/// Total account storage usage (used/total, all Proton products, not just
|
/// Total account storage usage (used/total, all Proton products, not just
|
||||||
@@ -743,7 +908,9 @@ pub enum Request {
|
|||||||
/// daemon performs (uploads, downloads, deletes, renames, shares, sync
|
/// daemon performs (uploads, downloads, deletes, renames, shares, sync
|
||||||
/// passes, …), so a front-end can show a running "what happened" feed
|
/// passes, …), so a front-end can show a running "what happened" feed
|
||||||
/// without re-deriving it from anywhere.
|
/// without re-deriving it from anywhere.
|
||||||
ListActivity { limit: usize },
|
ListActivity {
|
||||||
|
limit: usize,
|
||||||
|
},
|
||||||
|
|
||||||
// ---- push -------------------------------------------------------------
|
// ---- push -------------------------------------------------------------
|
||||||
/// Keep the connection open and stream [`Event`] lines instead of one
|
/// Keep the connection open and stream [`Event`] lines instead of one
|
||||||
@@ -761,6 +928,10 @@ pub enum Topic {
|
|||||||
Files,
|
Files,
|
||||||
/// The photos timeline or albums.
|
/// The photos timeline or albums.
|
||||||
Photos,
|
Photos,
|
||||||
|
/// The visible set of gallery media changed.
|
||||||
|
GalleryVisibility,
|
||||||
|
/// A remote Gallery visibility update arrived or its state became unavailable.
|
||||||
|
GalleryVisibilitySynced,
|
||||||
Trash,
|
Trash,
|
||||||
/// Shares, links, invitations and saved links, in either direction.
|
/// Shares, links, invitations and saved links, in either direction.
|
||||||
Shares,
|
Shares,
|
||||||
@@ -785,9 +956,11 @@ impl Topic {
|
|||||||
/// Every topic a front-end can act on. A new subscription is told all of
|
/// Every topic a front-end can act on. A new subscription is told all of
|
||||||
/// them have changed, so it catches up on whatever happened while it was
|
/// them have changed, so it catches up on whatever happened while it was
|
||||||
/// not connected.
|
/// not connected.
|
||||||
pub const ALL: [Topic; 10] = [
|
pub const ALL: [Topic; 12] = [
|
||||||
Topic::Files,
|
Topic::Files,
|
||||||
Topic::Photos,
|
Topic::Photos,
|
||||||
|
Topic::GalleryVisibility,
|
||||||
|
Topic::GalleryVisibilitySynced,
|
||||||
Topic::Trash,
|
Topic::Trash,
|
||||||
Topic::Shares,
|
Topic::Shares,
|
||||||
Topic::Devices,
|
Topic::Devices,
|
||||||
@@ -964,6 +1137,8 @@ pub enum SyncIssue {
|
|||||||
/// The account may no longer change the file or its folder, for example
|
/// The account may no longer change the file or its folder, for example
|
||||||
/// because a share was revoked.
|
/// because a share was revoked.
|
||||||
Access,
|
Access,
|
||||||
|
/// The item or a folder involved in a move can be restored from Trash.
|
||||||
|
Trashed,
|
||||||
/// The file or the folder it goes into is gone from Drive.
|
/// The file or the folder it goes into is gone from Drive.
|
||||||
Missing,
|
Missing,
|
||||||
/// The folder holds too many items, or is nested too deep.
|
/// The folder holds too many items, or is nested too deep.
|
||||||
@@ -981,6 +1156,7 @@ impl SyncIssue {
|
|||||||
match self {
|
match self {
|
||||||
SyncIssue::Quota => "quota",
|
SyncIssue::Quota => "quota",
|
||||||
SyncIssue::Access => "access",
|
SyncIssue::Access => "access",
|
||||||
|
SyncIssue::Trashed => "trashed",
|
||||||
SyncIssue::Missing => "missing",
|
SyncIssue::Missing => "missing",
|
||||||
SyncIssue::Limit => "limit",
|
SyncIssue::Limit => "limit",
|
||||||
SyncIssue::Rejected => "rejected",
|
SyncIssue::Rejected => "rejected",
|
||||||
@@ -993,6 +1169,7 @@ impl SyncIssue {
|
|||||||
match name {
|
match name {
|
||||||
"quota" => SyncIssue::Quota,
|
"quota" => SyncIssue::Quota,
|
||||||
"access" => SyncIssue::Access,
|
"access" => SyncIssue::Access,
|
||||||
|
"trashed" => SyncIssue::Trashed,
|
||||||
"missing" => SyncIssue::Missing,
|
"missing" => SyncIssue::Missing,
|
||||||
"limit" => SyncIssue::Limit,
|
"limit" => SyncIssue::Limit,
|
||||||
"rejected" => SyncIssue::Rejected,
|
"rejected" => SyncIssue::Rejected,
|
||||||
@@ -1827,6 +2004,56 @@ pub struct MappingProgress {
|
|||||||
pub total: usize,
|
pub total: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Actions on saved Drive folder galleries.
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub enum GalleryAction {
|
||||||
|
Unlock {
|
||||||
|
passphrase: String,
|
||||||
|
},
|
||||||
|
Lock,
|
||||||
|
List {
|
||||||
|
album: Option<GalleryPlace>,
|
||||||
|
offset: usize,
|
||||||
|
limit: usize,
|
||||||
|
},
|
||||||
|
Folders {
|
||||||
|
parent: Option<String>,
|
||||||
|
},
|
||||||
|
Add {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
Remove {
|
||||||
|
gallery: String,
|
||||||
|
},
|
||||||
|
Refresh,
|
||||||
|
Cover {
|
||||||
|
album: GalleryPlace,
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct GalleryPlace {
|
||||||
|
pub gallery: String,
|
||||||
|
pub album: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct GalleryFolder {
|
||||||
|
pub uid: String,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct GalleryAlbum {
|
||||||
|
pub place: GalleryPlace,
|
||||||
|
pub folder: GalleryFolder,
|
||||||
|
pub cover: Option<String>,
|
||||||
|
pub items: u64,
|
||||||
|
pub folders: u64,
|
||||||
|
pub hidden: bool,
|
||||||
|
}
|
||||||
|
|
||||||
/// One photo in a [`Request::PhotosTimeline`] page.
|
/// One photo in a [`Request::PhotosTimeline`] page.
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct PhotoItem {
|
pub struct PhotoItem {
|
||||||
@@ -2218,7 +2445,9 @@ pub enum Response {
|
|||||||
version: String,
|
version: String,
|
||||||
},
|
},
|
||||||
/// A human-readable success message.
|
/// A human-readable success message.
|
||||||
Ok { message: String },
|
Ok {
|
||||||
|
message: String,
|
||||||
|
},
|
||||||
/// Health report for the metadata database and content cache (reply to
|
/// Health report for the metadata database and content cache (reply to
|
||||||
/// [`Request::CacheInspect`]).
|
/// [`Request::CacheInspect`]).
|
||||||
CacheReport {
|
CacheReport {
|
||||||
@@ -2248,10 +2477,14 @@ pub enum Response {
|
|||||||
integrity_running: bool,
|
integrity_running: bool,
|
||||||
},
|
},
|
||||||
/// The pin registry.
|
/// The pin registry.
|
||||||
Pins { pins: Vec<Pin> },
|
Pins {
|
||||||
|
pins: Vec<Pin>,
|
||||||
|
},
|
||||||
/// A directory listing (reply to [`Request::ListDir`]) or a trash listing
|
/// A directory listing (reply to [`Request::ListDir`]) or a trash listing
|
||||||
/// (reply to [`Request::ListTrash`]).
|
/// (reply to [`Request::ListTrash`]).
|
||||||
Entries { entries: Vec<DirEntry> },
|
Entries {
|
||||||
|
entries: Vec<DirEntry>,
|
||||||
|
},
|
||||||
/// A page of the photos timeline. `available` is false when the account
|
/// A page of the photos timeline. `available` is false when the account
|
||||||
/// has no photos volume.
|
/// has no photos volume.
|
||||||
Photos {
|
Photos {
|
||||||
@@ -2264,6 +2497,22 @@ pub enum Response {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
counts: Option<(usize, usize, usize)>,
|
counts: Option<(usize, usize, usize)>,
|
||||||
},
|
},
|
||||||
|
GalleryFolders {
|
||||||
|
folders: Vec<GalleryFolder>,
|
||||||
|
},
|
||||||
|
GalleryPage {
|
||||||
|
albums: Vec<GalleryAlbum>,
|
||||||
|
items: Vec<PhotoItem>,
|
||||||
|
total: usize,
|
||||||
|
},
|
||||||
|
GalleryVideo {
|
||||||
|
url: String,
|
||||||
|
token: String,
|
||||||
|
size: u64,
|
||||||
|
},
|
||||||
|
GalleryThumbnail {
|
||||||
|
data: Option<String>,
|
||||||
|
},
|
||||||
/// The account's photo albums (reply to [`Request::PhotoAlbums`]).
|
/// The account's photo albums (reply to [`Request::PhotoAlbums`]).
|
||||||
/// `available` is false when the account has no photos volume, matching
|
/// `available` is false when the account has no photos volume, matching
|
||||||
/// [`Response::Photos`].
|
/// [`Response::Photos`].
|
||||||
@@ -2272,7 +2521,9 @@ pub enum Response {
|
|||||||
items: Vec<AlbumInfo>,
|
items: Vec<AlbumInfo>,
|
||||||
},
|
},
|
||||||
/// What the daemon is doing right now (reply to [`Request::Diagnostics`]).
|
/// What the daemon is doing right now (reply to [`Request::Diagnostics`]).
|
||||||
Diagnostics { diagnostics: Diagnostics },
|
Diagnostics {
|
||||||
|
diagnostics: Diagnostics,
|
||||||
|
},
|
||||||
/// How the Takeout import is doing (reply to [`Request::ImportStatus`]).
|
/// How the Takeout import is doing (reply to [`Request::ImportStatus`]).
|
||||||
/// `running` is false once it has finished, when `summary` is the final
|
/// `running` is false once it has finished, when `summary` is the final
|
||||||
/// report; `summary` is `None` when no import has run this session.
|
/// report; `summary` is `None` when no import has run this session.
|
||||||
@@ -2300,10 +2551,14 @@ pub enum Response {
|
|||||||
},
|
},
|
||||||
/// The months the timeline spans (reply to [`Request::PhotoMonths`]),
|
/// The months the timeline spans (reply to [`Request::PhotoMonths`]),
|
||||||
/// newest first.
|
/// newest first.
|
||||||
PhotoMonths { months: Vec<PhotoMonth> },
|
PhotoMonths {
|
||||||
|
months: Vec<PhotoMonth>,
|
||||||
|
},
|
||||||
/// The duplicate sets (reply to [`Request::PhotoDuplicates`]), newest
|
/// The duplicate sets (reply to [`Request::PhotoDuplicates`]), newest
|
||||||
/// first. Each set lists the copy worth keeping first.
|
/// first. Each set lists the copy worth keeping first.
|
||||||
PhotoDuplicates { sets: Vec<Vec<PhotoItem>> },
|
PhotoDuplicates {
|
||||||
|
sets: Vec<Vec<PhotoItem>>,
|
||||||
|
},
|
||||||
/// The sets of alike shots (reply to [`Request::PhotoSimilar`]), newest
|
/// The sets of alike shots (reply to [`Request::PhotoSimilar`]), newest
|
||||||
/// first, each in capture order; and how far hashing has got, `None`
|
/// first, each in capture order; and how far hashing has got, `None`
|
||||||
/// once no pass is running. `uncompared` counts the shots left out
|
/// once no pass is running. `uncompared` counts the shots left out
|
||||||
@@ -2325,9 +2580,13 @@ pub enum Response {
|
|||||||
},
|
},
|
||||||
/// The photos of one town, each with its location (reply to
|
/// The photos of one town, each with its location (reply to
|
||||||
/// [`Request::PlaceLocations`]).
|
/// [`Request::PlaceLocations`]).
|
||||||
PhotoLocations { items: Vec<PhotoLocation> },
|
PhotoLocations {
|
||||||
|
items: Vec<PhotoLocation>,
|
||||||
|
},
|
||||||
/// Thumbnails for a [`Request::PhotoThumbs`] batch.
|
/// Thumbnails for a [`Request::PhotoThumbs`] batch.
|
||||||
Thumbs { items: Vec<PhotoThumb> },
|
Thumbs {
|
||||||
|
items: Vec<PhotoThumb>,
|
||||||
|
},
|
||||||
/// Per-node outcome of a [`Request::TrashNodes`] batch. Reported per uid
|
/// Per-node outcome of a [`Request::TrashNodes`] batch. Reported per uid
|
||||||
/// rather than as one verdict: the server answers each node separately, and
|
/// rather than as one verdict: the server answers each node separately, and
|
||||||
/// a front-end that removed all of them on a partial success would show a
|
/// a front-end that removed all of them on a partial success would show a
|
||||||
@@ -2337,7 +2596,9 @@ pub enum Response {
|
|||||||
failed: Vec<TrashFailure>,
|
failed: Vec<TrashFailure>,
|
||||||
},
|
},
|
||||||
/// The album a [`Request::CreateAlbum`] made.
|
/// The album a [`Request::CreateAlbum`] made.
|
||||||
AlbumCreated { uid: String },
|
AlbumCreated {
|
||||||
|
uid: String,
|
||||||
|
},
|
||||||
/// Outcome of a [`Request::AddToAlbum`] or [`Request::RemoveFromAlbum`],
|
/// Outcome of a [`Request::AddToAlbum`] or [`Request::RemoveFromAlbum`],
|
||||||
/// per photo like [`Response::Trashed`]: `changed` photos were added or
|
/// per photo like [`Response::Trashed`]: `changed` photos were added or
|
||||||
/// removed, `failed` ones were not.
|
/// removed, `failed` ones were not.
|
||||||
@@ -2351,20 +2612,33 @@ pub enum Response {
|
|||||||
FileThumbsStale,
|
FileThumbsStale,
|
||||||
/// Daemon-issued generation reserved by
|
/// Daemon-issued generation reserved by
|
||||||
/// [`Request::ReserveFileThumbGeneration`].
|
/// [`Request::ReserveFileThumbGeneration`].
|
||||||
FileThumbGeneration { generation: u64 },
|
FileThumbGeneration {
|
||||||
|
generation: u64,
|
||||||
|
},
|
||||||
/// Current recursive thumbnail-build progress.
|
/// Current recursive thumbnail-build progress.
|
||||||
ThumbnailBuild { status: ThumbnailBuildStatus },
|
ThumbnailBuild {
|
||||||
|
status: ThumbnailBuildStatus,
|
||||||
|
},
|
||||||
/// Whether a photos-timeline refresh is still running (reply to
|
/// Whether a photos-timeline refresh is still running (reply to
|
||||||
/// [`Request::PhotosRefreshStatus`]).
|
/// [`Request::PhotosRefreshStatus`]).
|
||||||
PhotosRefresh { running: bool },
|
PhotosRefresh {
|
||||||
|
running: bool,
|
||||||
|
},
|
||||||
/// An on-disk path the front-end can open (e.g. a downloaded photo).
|
/// An on-disk path the front-end can open (e.g. a downloaded photo).
|
||||||
FilePath { path: String },
|
FilePath {
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
/// Full-text search results (reply to [`Request::Search`]).
|
/// Full-text search results (reply to [`Request::Search`]).
|
||||||
SearchResults { hits: Vec<SearchHit> },
|
SearchResults {
|
||||||
|
hits: Vec<SearchHit>,
|
||||||
|
},
|
||||||
/// Local-file search results (reply to [`Request::SearchLocal`]). `indexing`
|
/// Local-file search results (reply to [`Request::SearchLocal`]). `indexing`
|
||||||
/// is true while a scan of the machine is still running, so a front-end can
|
/// is true while a scan of the machine is still running, so a front-end can
|
||||||
/// say "still indexing" instead of "no matches" on a cold first launch.
|
/// say "still indexing" instead of "no matches" on a cold first launch.
|
||||||
LocalResults { hits: Vec<LocalHit>, indexing: bool },
|
LocalResults {
|
||||||
|
hits: Vec<LocalHit>,
|
||||||
|
indexing: bool,
|
||||||
|
},
|
||||||
/// Drive and local-file search results returned together (reply to
|
/// Drive and local-file search results returned together (reply to
|
||||||
/// [`Request::SearchV2`]). `local_indexing` distinguishes a genuinely empty
|
/// [`Request::SearchV2`]). `local_indexing` distinguishes a genuinely empty
|
||||||
/// local result set from one observed while the initial scan is running.
|
/// local result set from one observed while the initial scan is running.
|
||||||
@@ -2383,17 +2657,29 @@ pub enum Response {
|
|||||||
jobs: Vec<JobItem>,
|
jobs: Vec<JobItem>,
|
||||||
},
|
},
|
||||||
/// The account's devices (reply to [`Request::ListDevices`]).
|
/// The account's devices (reply to [`Request::ListDevices`]).
|
||||||
Devices { items: Vec<DeviceInfo> },
|
Devices {
|
||||||
|
items: Vec<DeviceInfo>,
|
||||||
|
},
|
||||||
/// Every local Proton Drive location (reply to [`Request::ListLocations`]).
|
/// Every local Proton Drive location (reply to [`Request::ListLocations`]).
|
||||||
Locations { items: Vec<MountSpec> },
|
Locations {
|
||||||
|
items: Vec<MountSpec>,
|
||||||
|
},
|
||||||
/// This device's synced folders (reply to [`Request::ListSyncFolders`]).
|
/// This device's synced folders (reply to [`Request::ListSyncFolders`]).
|
||||||
SyncFolders { items: Vec<SyncFolderInfo> },
|
SyncFolders {
|
||||||
|
items: Vec<SyncFolderInfo>,
|
||||||
|
},
|
||||||
/// The upload/change queue (reply to [`Request::ListPendingOps`]).
|
/// The upload/change queue (reply to [`Request::ListPendingOps`]).
|
||||||
PendingOps { items: Vec<PendingOpInfo> },
|
PendingOps {
|
||||||
|
items: Vec<PendingOpInfo>,
|
||||||
|
},
|
||||||
/// Conflict copies (reply to [`Request::ListConflicts`]).
|
/// Conflict copies (reply to [`Request::ListConflicts`]).
|
||||||
Conflicts { items: Vec<ConflictInfo> },
|
Conflicts {
|
||||||
|
items: Vec<ConflictInfo>,
|
||||||
|
},
|
||||||
/// Folders offered for restore (reply to [`Request::ListRestorableFolders`]).
|
/// Folders offered for restore (reply to [`Request::ListRestorableFolders`]).
|
||||||
RestorableFolders { items: Vec<RestorableFolder> },
|
RestorableFolders {
|
||||||
|
items: Vec<RestorableFolder>,
|
||||||
|
},
|
||||||
/// A node's share: members + pending invitations, and its public link if any
|
/// A node's share: members + pending invitations, and its public link if any
|
||||||
/// (reply to [`Request::ListShare`]).
|
/// (reply to [`Request::ListShare`]).
|
||||||
Share {
|
Share {
|
||||||
@@ -2403,28 +2689,46 @@ pub enum Response {
|
|||||||
/// A freshly created or changed public link, carrying the shareable URL
|
/// A freshly created or changed public link, carrying the shareable URL
|
||||||
/// (reply to [`Request::CreatePublicLink`] and
|
/// (reply to [`Request::CreatePublicLink`] and
|
||||||
/// [`Request::UpdatePublicLink`]).
|
/// [`Request::UpdatePublicLink`]).
|
||||||
PublicLink { link: PublicLinkInfo },
|
PublicLink {
|
||||||
|
link: PublicLinkInfo,
|
||||||
|
},
|
||||||
/// What a folder holds on Proton Drive (reply to [`Request::FolderSize`]):
|
/// What a folder holds on Proton Drive (reply to [`Request::FolderSize`]):
|
||||||
/// the bytes on storage and the number of items below it, folders and
|
/// the bytes on storage and the number of items below it, folders and
|
||||||
/// trashed items included.
|
/// trashed items included.
|
||||||
FolderSize { size: u64, items: u64 },
|
FolderSize {
|
||||||
|
size: u64,
|
||||||
|
items: u64,
|
||||||
|
},
|
||||||
/// Invitations addressed to me (reply to [`Request::ListInvitations`]).
|
/// Invitations addressed to me (reply to [`Request::ListInvitations`]).
|
||||||
Invitations { items: Vec<InvitationInfo> },
|
Invitations {
|
||||||
|
items: Vec<InvitationInfo>,
|
||||||
|
},
|
||||||
/// Saved public links (reply to [`Request::ListBookmarks`]).
|
/// Saved public links (reply to [`Request::ListBookmarks`]).
|
||||||
Bookmarks { items: Vec<BookmarkInfo> },
|
Bookmarks {
|
||||||
|
items: Vec<BookmarkInfo>,
|
||||||
|
},
|
||||||
/// Account storage usage in bytes (reply to [`Request::AccountQuota`]).
|
/// Account storage usage in bytes (reply to [`Request::AccountQuota`]).
|
||||||
/// `max_space` is the total; `used_space` what is consumed. `max_space == 0`
|
/// `max_space` is the total; `used_space` what is consumed. `max_space == 0`
|
||||||
/// means the total is unknown, which a front-end shows as a plain used figure
|
/// means the total is unknown, which a front-end shows as a plain used figure
|
||||||
/// rather than a full bar.
|
/// rather than a full bar.
|
||||||
AccountQuota { max_space: i64, used_space: i64 },
|
AccountQuota {
|
||||||
|
max_space: i64,
|
||||||
|
used_space: i64,
|
||||||
|
},
|
||||||
/// Nodes I have shared with others (reply to [`Request::ListSharedByMe`]).
|
/// Nodes I have shared with others (reply to [`Request::ListSharedByMe`]).
|
||||||
SharedByMe { items: Vec<SharedItem> },
|
SharedByMe {
|
||||||
|
items: Vec<SharedItem>,
|
||||||
|
},
|
||||||
/// A file's version history, newest first (reply to
|
/// A file's version history, newest first (reply to
|
||||||
/// [`Request::ListRevisions`]).
|
/// [`Request::ListRevisions`]).
|
||||||
Revisions { items: Vec<RevisionInfo> },
|
Revisions {
|
||||||
|
items: Vec<RevisionInfo>,
|
||||||
|
},
|
||||||
/// The daemon's recent activity, newest first (reply to
|
/// The daemon's recent activity, newest first (reply to
|
||||||
/// [`Request::ListActivity`]).
|
/// [`Request::ListActivity`]).
|
||||||
Activity { items: Vec<ActivityEntry> },
|
Activity {
|
||||||
|
items: Vec<ActivityEntry>,
|
||||||
|
},
|
||||||
/// The request failed. `message` is for the user; `kind` is for the code —
|
/// The request failed. `message` is for the user; `kind` is for the code —
|
||||||
/// a front-end decides its copy and whether to offer a retry from `kind`,
|
/// a front-end decides its copy and whether to offer a retry from `kind`,
|
||||||
/// never by matching on the text.
|
/// never by matching on the text.
|
||||||
@@ -2523,6 +2827,8 @@ impl Request {
|
|||||||
pub fn read_timeout(&self) -> Duration {
|
pub fn read_timeout(&self) -> Duration {
|
||||||
if self.is_poll() {
|
if self.is_poll() {
|
||||||
POLL_READ_TIMEOUT
|
POLL_READ_TIMEOUT
|
||||||
|
} else if matches!(self, Request::DriveGallery { .. }) {
|
||||||
|
Duration::from_secs(300)
|
||||||
} else {
|
} else {
|
||||||
READ_TIMEOUT
|
READ_TIMEOUT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,33 +163,47 @@ impl Db {
|
|||||||
album_uid: &str,
|
album_uid: &str,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
) -> Result<Vec<StoredPhoto>> {
|
||||||
|
self.album_photos_page_visible(album_uid, offset, limit, "[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn album_photos_page_visible(
|
||||||
|
&self,
|
||||||
|
album_uid: &str,
|
||||||
|
offset: usize,
|
||||||
|
limit: usize,
|
||||||
|
excluded: &str,
|
||||||
) -> Result<Vec<StoredPhoto>> {
|
) -> Result<Vec<StoredPhoto>> {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
let mut stmt = conn.prepare(
|
let mut stmt = conn.prepare(
|
||||||
"SELECT uid, capture_time, name, ratio, thumb_state, kind FROM album_photos
|
"SELECT uid, capture_time, name, ratio, thumb_state, kind FROM album_photos
|
||||||
WHERE album_uid = ?1 ORDER BY seq LIMIT ?2 OFFSET ?3",
|
WHERE album_uid = ?1 AND uid NOT IN (SELECT value FROM json_each(?4))
|
||||||
|
ORDER BY seq LIMIT ?2 OFFSET ?3",
|
||||||
)?;
|
)?;
|
||||||
let rows = stmt
|
let rows = stmt
|
||||||
.query_map(params![album_uid, limit as i64, offset as i64], |r| {
|
.query_map(
|
||||||
Ok(StoredPhoto {
|
params![album_uid, limit as i64, offset as i64, excluded],
|
||||||
uid: r.get(0)?,
|
|r| {
|
||||||
capture_time: r.get(1)?,
|
Ok(StoredPhoto {
|
||||||
name: r.get(2)?,
|
uid: r.get(0)?,
|
||||||
ratio: r.get(3)?,
|
capture_time: r.get(1)?,
|
||||||
thumb_state: r.get(4)?,
|
name: r.get(2)?,
|
||||||
kind: crate::control::PhotoKind::from_i64(r.get(5)?),
|
ratio: r.get(3)?,
|
||||||
// Album rows have no favorite state of their own: an album
|
thumb_state: r.get(4)?,
|
||||||
// photo on someone else's volume is not in our timeline, and
|
kind: crate::control::PhotoKind::from_i64(r.get(5)?),
|
||||||
// favouriting one is not supported yet anyway.
|
// Album rows have no favorite state of their own: an album
|
||||||
favorite: false,
|
// photo on someone else's volume is not in our timeline, and
|
||||||
// Nor are album rows grouped: an album is a list the user
|
// favouriting one is not supported yet anyway.
|
||||||
// made, and it shows exactly what they put in it.
|
favorite: false,
|
||||||
group_size: 1,
|
// Nor are album rows grouped: an album is a list the user
|
||||||
has_raw: false,
|
// made, and it shows exactly what they put in it.
|
||||||
// Album rows carry no location.
|
group_size: 1,
|
||||||
place_id: None,
|
has_raw: false,
|
||||||
})
|
// Album rows carry no location.
|
||||||
})?
|
place_id: None,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)?
|
||||||
.collect::<rusqlite::Result<_>>()?;
|
.collect::<rusqlite::Result<_>>()?;
|
||||||
Ok(rows)
|
Ok(rows)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ impl Db {
|
|||||||
Ok(total.max(0) as u64)
|
Ok(total.max(0) as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `limit` least-recently-accessed entries of `kind`, oldest first.
|
/// The `limit` least-recently-accessed entries of `kind` after `offset`,
|
||||||
|
/// oldest first.
|
||||||
///
|
///
|
||||||
/// Eviction wants a handful of victims, not the whole table. Bounded so a
|
/// Eviction wants a handful of victims, not the whole table. Bounded so a
|
||||||
/// pass over a large cache does not read every row to drop a few, and so the
|
/// pass over a large cache does not read every row to drop a few, and so the
|
||||||
@@ -118,13 +119,14 @@ impl Db {
|
|||||||
&self,
|
&self,
|
||||||
kind: &str,
|
kind: &str,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
offset: usize,
|
||||||
) -> Result<Vec<(String, u64)>> {
|
) -> Result<Vec<(String, u64)>> {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
let mut stmt = conn.prepare_cached(
|
let mut stmt = conn.prepare_cached(
|
||||||
"SELECT cache_key, size_bytes FROM cache_entries
|
"SELECT cache_key, size_bytes FROM cache_entries
|
||||||
WHERE kind = ?1 ORDER BY last_accessed ASC LIMIT ?2",
|
WHERE kind = ?1 ORDER BY last_accessed ASC LIMIT ?2 OFFSET ?3",
|
||||||
)?;
|
)?;
|
||||||
let rows = stmt.query_map(params![kind, limit as i64], |r| {
|
let rows = stmt.query_map(params![kind, limit as i64, offset as i64], |r| {
|
||||||
Ok((r.get::<_, String>(0)?, r.get::<_, i64>(1)?.max(0) as u64))
|
Ok((r.get::<_, String>(0)?, r.get::<_, i64>(1)?.max(0) as u64))
|
||||||
})?;
|
})?;
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
|
|||||||
@@ -252,9 +252,32 @@ const UID_NOW: &str = "COALESCE((SELECT uid FROM nodes WHERE lid = pending_op.li
|
|||||||
const PARENT_NOW: &str =
|
const PARENT_NOW: &str =
|
||||||
"COALESCE((SELECT uid FROM nodes WHERE lid = pending_op.parent_lid), parent_uid)";
|
"COALESCE((SELECT uid FROM nodes WHERE lid = pending_op.parent_lid), parent_uid)";
|
||||||
|
|
||||||
|
/// Whether any queued move takes a node out of the folder `source.uid`.
|
||||||
|
/// A move updates the local node tree immediately, so its original parent
|
||||||
|
/// comes from the queue, including while a worker is sending it to Drive.
|
||||||
|
const MOVES_OUT_OF_FOLDER: &str = "
|
||||||
|
COALESCE((SELECT is_dir FROM nodes WHERE uid = source.uid), 1) = 1
|
||||||
|
AND EXISTS (
|
||||||
|
WITH RECURSIVE folders(uid, lid) AS (
|
||||||
|
SELECT source.uid, (SELECT lid FROM nodes WHERE uid = source.uid)
|
||||||
|
UNION
|
||||||
|
SELECT n.uid, n.lid FROM nodes n JOIN folders f
|
||||||
|
ON n.parent_lid = f.lid OR (n.parent_lid IS NULL AND n.parent_uid = f.uid)
|
||||||
|
WHERE n.is_dir = 1
|
||||||
|
)
|
||||||
|
SELECT 1 FROM pending_op AS move
|
||||||
|
WHERE move.kind = 'rename'
|
||||||
|
AND CASE WHEN json_valid(move.meta_json)
|
||||||
|
THEN json_extract(move.meta_json, '$.original_parent_uid') END
|
||||||
|
IN (SELECT uid FROM folders)
|
||||||
|
AND move.parent_uid IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM folders f
|
||||||
|
WHERE f.lid = move.parent_lid OR f.uid = move.parent_uid)
|
||||||
|
)";
|
||||||
|
|
||||||
/// The `WHERE` terms for a row a drain worker may claim once it falls due: not
|
/// The `WHERE` terms for a row a drain worker may claim once it falls due: not
|
||||||
/// claimed already, no other claimed op on the same node, and not under a
|
/// claimed already, no other claimed op on the same node, no pending creation
|
||||||
/// folder that has yet to land.
|
/// of its parent, and no moves that still need a folder we are about to trash.
|
||||||
///
|
///
|
||||||
/// One fragment for [`Db::claim_next_due_op`] and [`Db::earliest_due_at`]. A
|
/// One fragment for [`Db::claim_next_due_op`] and [`Db::earliest_due_at`]. A
|
||||||
/// row the claim skips but the wait counts is due "now" for as long as it is
|
/// row the claim skips but the wait counts is due "now" for as long as it is
|
||||||
@@ -265,7 +288,9 @@ fn claimable() -> String {
|
|||||||
AND (parent_uid IS NULL OR substr({PARENT_NOW}, 1, {n}) <> '{v}~')
|
AND (parent_uid IS NULL OR substr({PARENT_NOW}, 1, {n}) <> '{v}~')
|
||||||
AND uid NOT IN (SELECT uid FROM pending_op WHERE claimed_at <> 0)
|
AND uid NOT IN (SELECT uid FROM pending_op WHERE claimed_at <> 0)
|
||||||
AND (lid IS NULL OR lid NOT IN (
|
AND (lid IS NULL OR lid NOT IN (
|
||||||
SELECT lid FROM pending_op WHERE claimed_at <> 0 AND lid IS NOT NULL))",
|
SELECT lid FROM pending_op WHERE claimed_at <> 0 AND lid IS NOT NULL))
|
||||||
|
AND (kind <> 'trash' OR NOT EXISTS (
|
||||||
|
SELECT 1 FROM (SELECT {UID_NOW} AS uid) AS source WHERE {MOVES_OUT_OF_FOLDER}))",
|
||||||
v = LOCAL_VOLUME,
|
v = LOCAL_VOLUME,
|
||||||
n = LOCAL_VOLUME.len() + 1,
|
n = LOCAL_VOLUME.len() + 1,
|
||||||
)
|
)
|
||||||
@@ -475,19 +500,40 @@ pub struct AttachedBlob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Db {
|
impl Db {
|
||||||
/// Whether a queued trash still holds `name` somewhere.
|
/// A folder can look empty locally while Drive still holds the queued
|
||||||
|
/// moves' source files. A trash has to go through the drain in that case.
|
||||||
|
pub fn has_pending_moves_out_of(&self, uid: &str) -> Result<bool> {
|
||||||
|
let conn = self.read();
|
||||||
|
Ok(conn
|
||||||
|
.prepare_cached(&format!(
|
||||||
|
"SELECT EXISTS (SELECT 1 FROM (SELECT ?1 AS uid) AS source
|
||||||
|
WHERE {MOVES_OUT_OF_FOLDER})"
|
||||||
|
))?
|
||||||
|
.query_row(params![uid], |row| row.get(0))?)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether a queued trash still holds `name` in `parent_uid`.
|
||||||
///
|
///
|
||||||
/// A replacing rename or a delete-then-recreate queues the trash of the old
|
/// A replacing rename or a delete-then-recreate queues the trash of the old
|
||||||
/// node ahead of the op that wants its name. With several drain workers the
|
/// node ahead of the op that wants its name. With several drain workers the
|
||||||
/// later op can run first and find the name still taken; this tells it to
|
/// later op can run first and find the name still taken; this tells it to
|
||||||
/// wait for the trash rather than land under a conflict name.
|
/// wait for the trash rather than land under a conflict name. Older rows
|
||||||
pub fn has_pending_trash_named(&self, name: &str) -> Result<bool> {
|
/// whose node and parent are unknown are matched by name alone.
|
||||||
|
pub fn has_pending_trash_named(&self, name: &str, parent_uid: Option<&str>) -> Result<bool> {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
conn.query_row(
|
conn.query_row(
|
||||||
"SELECT EXISTS(
|
"SELECT EXISTS(
|
||||||
SELECT 1 FROM pending_op WHERE kind = ?1 AND name = ?2
|
SELECT 1 FROM pending_op AS p
|
||||||
)",
|
WHERE p.kind = ?1 AND p.name = ?2
|
||||||
params![OP_TRASH, name],
|
AND (?3 IS NULL OR ?3 = COALESCE(
|
||||||
|
(SELECT uid FROM nodes WHERE lid = p.parent_lid),
|
||||||
|
p.parent_uid,
|
||||||
|
(SELECT COALESCE(parent.uid, n.parent_uid)
|
||||||
|
FROM nodes n LEFT JOIN nodes parent ON parent.lid = n.parent_lid
|
||||||
|
WHERE n.uid = p.uid),
|
||||||
|
?3))
|
||||||
|
)",
|
||||||
|
params![OP_TRASH, name, parent_uid],
|
||||||
|row| row.get(0),
|
|row| row.get(0),
|
||||||
)
|
)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
@@ -1219,7 +1265,7 @@ impl Db {
|
|||||||
/// the claim is a column: a row is offered to exactly one worker, and the
|
/// the claim is a column: a row is offered to exactly one worker, and the
|
||||||
/// worker that took it is the only one that may retire, defer or fail it.
|
/// worker that took it is the only one that may retire, defer or fail it.
|
||||||
///
|
///
|
||||||
/// Two exclusions on top of [`next_due_op`](Self::next_due_op)'s:
|
/// The selected row must also satisfy [`claimable`]:
|
||||||
///
|
///
|
||||||
/// * `claimed_at = 0` — not already in flight somewhere else.
|
/// * `claimed_at = 0` — not already in flight somewhere else.
|
||||||
/// * no *other* claimed op shares this `uid`. Ordering only has to hold per
|
/// * no *other* claimed op shares this `uid`. Ordering only has to hold per
|
||||||
@@ -1229,6 +1275,8 @@ impl Db {
|
|||||||
/// pending entry. `ORDER BY id` plus this exclusion gives per-uid serial
|
/// pending entry. `ORDER BY id` plus this exclusion gives per-uid serial
|
||||||
/// order for free — the older op is claimed first and the newer one is
|
/// order for free — the older op is claimed first and the newer one is
|
||||||
/// invisible until it retires.
|
/// invisible until it retires.
|
||||||
|
/// * its destination folder already exists remotely.
|
||||||
|
/// * a folder trash waits for pending moves out of that folder's subtree.
|
||||||
///
|
///
|
||||||
/// Select and mark are one transaction, so two workers cannot both see the
|
/// Select and mark are one transaction, so two workers cannot both see the
|
||||||
/// row as unclaimed.
|
/// row as unclaimed.
|
||||||
|
|||||||
@@ -513,24 +513,42 @@ impl Db {
|
|||||||
range: Option<(i64, i64)>,
|
range: Option<(i64, i64)>,
|
||||||
favorites: bool,
|
favorites: bool,
|
||||||
not_in_album: bool,
|
not_in_album: bool,
|
||||||
|
) -> Result<Vec<StoredPhoto>> {
|
||||||
|
self.photos_page_visible(offset, limit, kind, range, favorites, not_in_album, "[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn photos_page_visible(
|
||||||
|
&self,
|
||||||
|
offset: usize,
|
||||||
|
limit: usize,
|
||||||
|
kind: Option<crate::control::PhotoKind>,
|
||||||
|
range: Option<(i64, i64)>,
|
||||||
|
favorites: bool,
|
||||||
|
not_in_album: bool,
|
||||||
|
excluded: &str,
|
||||||
) -> Result<Vec<StoredPhoto>> {
|
) -> Result<Vec<StoredPhoto>> {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
// Built up so any combination of the optional filters is one indexed
|
// Built up so any combination of the optional filters is one indexed
|
||||||
// query rather than a statement per case.
|
// query rather than a statement per case.
|
||||||
let mut sql = String::from(PHOTO_SELECT);
|
let mut sql = String::from(PHOTO_SELECT);
|
||||||
let mut binds: Vec<i64> = Vec::new();
|
let mut binds: Vec<rusqlite::types::Value> = Vec::new();
|
||||||
let mut conds: Vec<String> = Vec::new();
|
let mut conds: Vec<String> = Vec::new();
|
||||||
|
if excluded != "[]" {
|
||||||
|
binds.push(excluded.to_owned().into());
|
||||||
|
conds.push("p.uid NOT IN (SELECT value FROM json_each(?1))".to_owned());
|
||||||
|
}
|
||||||
if kind != Some(crate::control::PhotoKind::Raw) {
|
if kind != Some(crate::control::PhotoKind::Raw) {
|
||||||
conds.push("p.uid = COALESCE(p.group_key, p.uid)".to_string());
|
conds.push("p.uid = COALESCE(p.group_key, p.uid)".to_string());
|
||||||
}
|
}
|
||||||
if let Some(k) = kind {
|
if let Some(k) = kind {
|
||||||
binds.push(k.as_i64());
|
binds.push((k.as_i64()).into());
|
||||||
conds.push(format!("p.kind = ?{}", binds.len()));
|
conds.push(format!("p.kind = ?{}", binds.len()));
|
||||||
}
|
}
|
||||||
if let Some((from, to)) = range {
|
if let Some((from, to)) = range {
|
||||||
binds.push(from);
|
binds.push((from).into());
|
||||||
conds.push(format!("p.capture_time >= ?{}", binds.len()));
|
conds.push(format!("p.capture_time >= ?{}", binds.len()));
|
||||||
binds.push(to);
|
binds.push((to).into());
|
||||||
conds.push(format!("p.capture_time < ?{}", binds.len()));
|
conds.push(format!("p.capture_time < ?{}", binds.len()));
|
||||||
}
|
}
|
||||||
if favorites {
|
if favorites {
|
||||||
@@ -549,9 +567,9 @@ impl Db {
|
|||||||
sql.push_str(" WHERE ");
|
sql.push_str(" WHERE ");
|
||||||
sql.push_str(&conds.join(" AND "));
|
sql.push_str(&conds.join(" AND "));
|
||||||
}
|
}
|
||||||
binds.push(limit as i64);
|
binds.push((limit as i64).into());
|
||||||
let limit_pos = binds.len();
|
let limit_pos = binds.len();
|
||||||
binds.push(offset as i64);
|
binds.push((offset as i64).into());
|
||||||
let offset_pos = binds.len();
|
let offset_pos = binds.len();
|
||||||
sql.push_str(&format!(
|
sql.push_str(&format!(
|
||||||
" ORDER BY p.seq LIMIT ?{limit_pos} OFFSET ?{offset_pos}"
|
" ORDER BY p.seq LIMIT ?{limit_pos} OFFSET ?{offset_pos}"
|
||||||
@@ -580,6 +598,25 @@ impl Db {
|
|||||||
Ok(rows)
|
Ok(rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Include associated files so a public preview cannot reveal a hidden
|
||||||
|
/// RAW, JPEG or Live Photo through another part of the same shot.
|
||||||
|
pub fn photo_group_members_for(&self, uids: &HashSet<String>) -> Result<HashSet<String>> {
|
||||||
|
if uids.is_empty() {
|
||||||
|
return Ok(HashSet::new());
|
||||||
|
}
|
||||||
|
let ids = serde_json::to_string(uids).expect("file identifiers serialize");
|
||||||
|
let conn = self.read();
|
||||||
|
let mut query = conn.prepare(
|
||||||
|
"SELECT uid FROM photos WHERE COALESCE(group_key, uid) IN (
|
||||||
|
SELECT COALESCE(group_key, uid) FROM photos
|
||||||
|
WHERE uid IN (SELECT value FROM json_each(?1))
|
||||||
|
)",
|
||||||
|
)?;
|
||||||
|
Ok(query
|
||||||
|
.query_map([ids], |row| row.get(0))?
|
||||||
|
.collect::<rusqlite::Result<_>>()?)
|
||||||
|
}
|
||||||
|
|
||||||
/// The whole persisted timeline, in stored order — every file, not one row
|
/// The whole persisted timeline, in stored order — every file, not one row
|
||||||
/// per group. Only for whole-library passes (the photo re-date); the gallery
|
/// per group. Only for whole-library passes (the photo re-date); the gallery
|
||||||
/// pages with [`Db::photos_page`].
|
/// pages with [`Db::photos_page`].
|
||||||
@@ -601,27 +638,33 @@ impl Db {
|
|||||||
pub fn photos_months(
|
pub fn photos_months(
|
||||||
&self,
|
&self,
|
||||||
kind: Option<crate::control::PhotoKind>,
|
kind: Option<crate::control::PhotoKind>,
|
||||||
|
) -> Result<Vec<(i32, i32, usize)>> {
|
||||||
|
self.photos_months_visible(kind, "[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn photos_months_visible(
|
||||||
|
&self,
|
||||||
|
kind: Option<crate::control::PhotoKind>,
|
||||||
|
excluded: &str,
|
||||||
) -> Result<Vec<(i32, i32, usize)>> {
|
) -> Result<Vec<(i32, i32, usize)>> {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
// The scrubber has to agree with the page it scrubs, so it counts what
|
// The scrubber has to agree with the page it scrubs, so it counts what
|
||||||
// the page shows: groups everywhere except on the Raw tab.
|
// the page shows: groups everywhere except on the Raw tab.
|
||||||
let (filter, binds): (&str, Vec<i64>) = match kind {
|
let filter = match kind {
|
||||||
Some(crate::control::PhotoKind::Raw) => (" WHERE kind = 2", Vec::new()),
|
Some(crate::control::PhotoKind::Raw) => "kind = ?2",
|
||||||
Some(k) => (
|
Some(_) => "uid = COALESCE(group_key, uid) AND kind = ?2",
|
||||||
" WHERE uid = COALESCE(group_key, uid) AND kind = ?1",
|
None => "uid = COALESCE(group_key, uid) AND ?2 IS NULL",
|
||||||
vec![k.as_i64()],
|
|
||||||
),
|
|
||||||
None => (" WHERE uid = COALESCE(group_key, uid)", Vec::new()),
|
|
||||||
};
|
};
|
||||||
let sql = format!(
|
let sql = format!(
|
||||||
"SELECT CAST(strftime('%Y', capture_time, 'unixepoch', 'localtime') AS INTEGER) AS y, \
|
"SELECT CAST(strftime('%Y', capture_time, 'unixepoch', 'localtime') AS INTEGER) AS y, \
|
||||||
CAST(strftime('%m', capture_time, 'unixepoch', 'localtime') AS INTEGER) AS m, \
|
CAST(strftime('%m', capture_time, 'unixepoch', 'localtime') AS INTEGER) AS m, \
|
||||||
COUNT(*) \
|
COUNT(*) \
|
||||||
FROM photos{filter} GROUP BY y, m ORDER BY y DESC, m DESC"
|
FROM photos WHERE {filter} AND uid NOT IN (SELECT value FROM json_each(?1))
|
||||||
|
GROUP BY y, m ORDER BY y DESC, m DESC"
|
||||||
);
|
);
|
||||||
let mut stmt = conn.prepare(&sql)?;
|
let mut stmt = conn.prepare(&sql)?;
|
||||||
let rows = stmt
|
let rows = stmt
|
||||||
.query_map(rusqlite::params_from_iter(binds), |r| {
|
.query_map(params![excluded, kind.map(|kind| kind.as_i64())], |r| {
|
||||||
Ok((
|
Ok((
|
||||||
r.get::<_, i32>(0)?,
|
r.get::<_, i32>(0)?,
|
||||||
r.get::<_, i32>(1)?,
|
r.get::<_, i32>(1)?,
|
||||||
@@ -637,6 +680,15 @@ impl Db {
|
|||||||
/// pick the date, and its own year is left out, because today's photos are
|
/// pick the date, and its own year is left out, because today's photos are
|
||||||
/// what the timeline already opens on. One row per group, like the timeline.
|
/// what the timeline already opens on. One row per group, like the timeline.
|
||||||
pub fn photos_on_this_day(&self, today: i64, limit: usize) -> Result<Vec<StoredPhoto>> {
|
pub fn photos_on_this_day(&self, today: i64, limit: usize) -> Result<Vec<StoredPhoto>> {
|
||||||
|
self.photos_on_this_day_visible(today, limit, "[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn photos_on_this_day_visible(
|
||||||
|
&self,
|
||||||
|
today: i64,
|
||||||
|
limit: usize,
|
||||||
|
excluded: &str,
|
||||||
|
) -> Result<Vec<StoredPhoto>> {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
let sql = format!(
|
let sql = format!(
|
||||||
"{PHOTO_SELECT} WHERE p.uid = COALESCE(p.group_key, p.uid) \
|
"{PHOTO_SELECT} WHERE p.uid = COALESCE(p.group_key, p.uid) \
|
||||||
@@ -644,11 +696,12 @@ impl Db {
|
|||||||
= strftime('%m-%d', ?1, 'unixepoch', 'localtime') \
|
= strftime('%m-%d', ?1, 'unixepoch', 'localtime') \
|
||||||
AND strftime('%Y', p.capture_time, 'unixepoch', 'localtime') \
|
AND strftime('%Y', p.capture_time, 'unixepoch', 'localtime') \
|
||||||
< strftime('%Y', ?1, 'unixepoch', 'localtime') \
|
< strftime('%Y', ?1, 'unixepoch', 'localtime') \
|
||||||
|
AND p.uid NOT IN (SELECT value FROM json_each(?3))
|
||||||
ORDER BY p.seq LIMIT ?2"
|
ORDER BY p.seq LIMIT ?2"
|
||||||
);
|
);
|
||||||
let mut stmt = conn.prepare(&sql)?;
|
let mut stmt = conn.prepare(&sql)?;
|
||||||
let rows = stmt
|
let rows = stmt
|
||||||
.query_map(params![today, limit as i64], stored_photo)?
|
.query_map(params![today, limit as i64, excluded], stored_photo)?
|
||||||
.collect::<rusqlite::Result<_>>()?;
|
.collect::<rusqlite::Result<_>>()?;
|
||||||
Ok(rows)
|
Ok(rows)
|
||||||
}
|
}
|
||||||
@@ -657,6 +710,10 @@ impl Db {
|
|||||||
/// cover, most photographed first. Counted per group, like the timeline;
|
/// cover, most photographed first. Counted per group, like the timeline;
|
||||||
/// photos without a location, or taken far from any town, are in none.
|
/// photos without a location, or taken far from any town, are in none.
|
||||||
pub fn photo_places(&self) -> Result<Vec<StoredPlace>> {
|
pub fn photo_places(&self) -> Result<Vec<StoredPlace>> {
|
||||||
|
self.photo_places_visible("[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn photo_places_visible(&self, excluded: &str) -> Result<Vec<StoredPlace>> {
|
||||||
let rows: Vec<(u32, usize, String)> = {
|
let rows: Vec<(u32, usize, String)> = {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
// SQLite fills the bare `uid` from the row `MIN(seq)` picked, which
|
// SQLite fills the bare `uid` from the row `MIN(seq)` picked, which
|
||||||
@@ -664,9 +721,10 @@ impl Db {
|
|||||||
let mut stmt = conn.prepare(
|
let mut stmt = conn.prepare(
|
||||||
"SELECT place_id, COUNT(*), uid, MIN(seq) FROM photos \
|
"SELECT place_id, COUNT(*), uid, MIN(seq) FROM photos \
|
||||||
WHERE uid = COALESCE(group_key, uid) AND place_id IS NOT NULL \
|
WHERE uid = COALESCE(group_key, uid) AND place_id IS NOT NULL \
|
||||||
|
AND uid NOT IN (SELECT value FROM json_each(?1))
|
||||||
GROUP BY place_id ORDER BY COUNT(*) DESC, MIN(seq)",
|
GROUP BY place_id ORDER BY COUNT(*) DESC, MIN(seq)",
|
||||||
)?;
|
)?;
|
||||||
stmt.query_map([], |r| {
|
stmt.query_map([excluded], |r| {
|
||||||
Ok((r.get(0)?, r.get::<_, i64>(1)? as usize, r.get(2)?))
|
Ok((r.get(0)?, r.get::<_, i64>(1)? as usize, r.get(2)?))
|
||||||
})?
|
})?
|
||||||
.collect::<rusqlite::Result<_>>()?
|
.collect::<rusqlite::Result<_>>()?
|
||||||
@@ -695,15 +753,29 @@ impl Db {
|
|||||||
id: u32,
|
id: u32,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
) -> Result<Vec<StoredPhoto>> {
|
||||||
|
self.photos_at_place_visible(id, offset, limit, "[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn photos_at_place_visible(
|
||||||
|
&self,
|
||||||
|
id: u32,
|
||||||
|
offset: usize,
|
||||||
|
limit: usize,
|
||||||
|
excluded: &str,
|
||||||
) -> Result<Vec<StoredPhoto>> {
|
) -> Result<Vec<StoredPhoto>> {
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
let sql = format!(
|
let sql = format!(
|
||||||
"{PHOTO_SELECT} WHERE p.uid = COALESCE(p.group_key, p.uid) AND p.place_id = ?1 \
|
"{PHOTO_SELECT} WHERE p.uid = COALESCE(p.group_key, p.uid) AND p.place_id = ?1
|
||||||
|
AND p.uid NOT IN (SELECT value FROM json_each(?4))
|
||||||
ORDER BY p.seq LIMIT ?2 OFFSET ?3"
|
ORDER BY p.seq LIMIT ?2 OFFSET ?3"
|
||||||
);
|
);
|
||||||
let mut stmt = conn.prepare(&sql)?;
|
let mut stmt = conn.prepare(&sql)?;
|
||||||
let rows = stmt
|
let rows = stmt
|
||||||
.query_map(params![id, limit as i64, offset as i64], stored_photo)?
|
.query_map(
|
||||||
|
params![id, limit as i64, offset as i64, excluded],
|
||||||
|
stored_photo,
|
||||||
|
)?
|
||||||
.collect::<rusqlite::Result<_>>()?;
|
.collect::<rusqlite::Result<_>>()?;
|
||||||
Ok(rows)
|
Ok(rows)
|
||||||
}
|
}
|
||||||
@@ -884,6 +956,10 @@ impl Db {
|
|||||||
|
|
||||||
/// Per-tab counts for the Photos page subtitle: `(photos, videos, raw)`.
|
/// Per-tab counts for the Photos page subtitle: `(photos, videos, raw)`.
|
||||||
pub fn photos_counts(&self) -> Result<(usize, usize, usize)> {
|
pub fn photos_counts(&self) -> Result<(usize, usize, usize)> {
|
||||||
|
self.photos_counts_visible("[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn photos_counts_visible(&self, excluded: &str) -> Result<(usize, usize, usize)> {
|
||||||
use crate::control::PhotoKind;
|
use crate::control::PhotoKind;
|
||||||
let conn = self.read();
|
let conn = self.read();
|
||||||
// Photos and Videos count groups — one shot is one entry, however many
|
// Photos and Videos count groups — one shot is one entry, however many
|
||||||
@@ -891,9 +967,12 @@ impl Db {
|
|||||||
// them individually.
|
// them individually.
|
||||||
let mut stmt = conn.prepare(
|
let mut stmt = conn.prepare(
|
||||||
"SELECT kind, COUNT(*) FROM photos \
|
"SELECT kind, COUNT(*) FROM photos \
|
||||||
WHERE uid = COALESCE(group_key, uid) OR kind = 2 GROUP BY kind",
|
WHERE (uid = COALESCE(group_key, uid) OR kind = 2)
|
||||||
|
AND uid NOT IN (SELECT value FROM json_each(?1)) GROUP BY kind",
|
||||||
)?;
|
)?;
|
||||||
let rows = stmt.query_map([], |r| Ok((r.get::<_, i64>(0)?, r.get::<_, i64>(1)?)))?;
|
let rows = stmt.query_map([excluded], |r| {
|
||||||
|
Ok((r.get::<_, i64>(0)?, r.get::<_, i64>(1)?))
|
||||||
|
})?;
|
||||||
let (mut photos, mut videos, mut raw) = (0usize, 0usize, 0usize);
|
let (mut photos, mut videos, mut raw) = (0usize, 0usize, 0usize);
|
||||||
for row in rows {
|
for row in rows {
|
||||||
let (kind, n) = row?;
|
let (kind, n) = row?;
|
||||||
|
|||||||
@@ -337,6 +337,10 @@ fn places_group_photos_by_the_nearest_town() {
|
|||||||
.map(|p| p.uid)
|
.map(|p| p.uid)
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(berlin, ["b2", "b1-jpeg"]);
|
assert_eq!(berlin, ["b2", "b1-jpeg"]);
|
||||||
|
let visible = db.photo_places_visible(r#"["b2","p1"]"#).unwrap();
|
||||||
|
assert_eq!(visible.len(), 1);
|
||||||
|
assert_eq!(visible[0].count, 1);
|
||||||
|
assert_eq!(visible[0].cover.uid, "b1-jpeg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A town's photos come with where each was taken, one per RAW+JPEG shot.
|
/// A town's photos come with where each was taken, one per RAW+JPEG shot.
|
||||||
@@ -2740,15 +2744,34 @@ fn atomic_trash_replacement_returns_owned_blobs_after_commit() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn a_queued_trash_holds_its_name_until_it_lands() {
|
fn a_queued_trash_holds_its_name_until_it_lands() {
|
||||||
let db = Db::open_in_memory().unwrap();
|
let db = Db::open_in_memory().unwrap();
|
||||||
|
db.upsert_node(&file("held-name", "root", "report.txt", 1))
|
||||||
|
.unwrap();
|
||||||
let node = uid("held-name").to_string();
|
let node = uid("held-name").to_string();
|
||||||
assert!(!db.has_pending_trash_named("report.txt").unwrap());
|
let root = uid("root").to_string();
|
||||||
|
assert!(
|
||||||
|
!db.has_pending_trash_named("report.txt", Some(&root))
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
let (trash_id, _) = db.replace_ops_with_trash(&node, "report.txt", 1).unwrap();
|
let (trash_id, _) = db.replace_ops_with_trash(&node, "report.txt", 1).unwrap();
|
||||||
assert!(db.has_pending_trash_named("report.txt").unwrap());
|
assert!(
|
||||||
assert!(!db.has_pending_trash_named("other.txt").unwrap());
|
db.has_pending_trash_named("report.txt", Some(&root))
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!db.has_pending_trash_named("other.txt", Some(&root))
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!db.has_pending_trash_named("report.txt", Some(&uid("other").to_string()))
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
db.delete_op(trash_id).unwrap();
|
db.delete_op(trash_id).unwrap();
|
||||||
assert!(!db.has_pending_trash_named("report.txt").unwrap());
|
assert!(
|
||||||
|
!db.has_pending_trash_named("report.txt", Some(&root))
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A create that found its name held by a queued trash backed off. The trash
|
/// A create that found its name held by a queued trash backed off. The trash
|
||||||
@@ -6094,7 +6117,7 @@ fn cache_eviction_candidates_are_lru_ordered_and_limited() {
|
|||||||
}
|
}
|
||||||
db.cache_touch("other", "block", 100, 0).unwrap();
|
db.cache_touch("other", "block", 100, 0).unwrap();
|
||||||
|
|
||||||
let batch = db.cache_eviction_candidates("blob", 3).unwrap();
|
let batch = db.cache_eviction_candidates("blob", 3, 0).unwrap();
|
||||||
assert_eq!(batch.len(), 3, "honours the limit");
|
assert_eq!(batch.len(), 3, "honours the limit");
|
||||||
let keys: Vec<&str> = batch.iter().map(|(k, _)| k.as_str()).collect();
|
let keys: Vec<&str> = batch.iter().map(|(k, _)| k.as_str()).collect();
|
||||||
assert_eq!(keys, ["k9", "k8", "k7"], "least-recently-accessed first");
|
assert_eq!(keys, ["k9", "k8", "k7"], "least-recently-accessed first");
|
||||||
@@ -6925,6 +6948,54 @@ fn two_workers_never_share_a_node() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn trashing_a_folder_waits_for_moves_out_of_its_subtree() {
|
||||||
|
let db = Db::open_in_memory().unwrap();
|
||||||
|
db.upsert_nodes(&[
|
||||||
|
folder("root", None, "My Files"),
|
||||||
|
folder("source", Some("root"), "source"),
|
||||||
|
folder("nested", Some("source"), "nested"),
|
||||||
|
folder("destination", Some("root"), "destination"),
|
||||||
|
file("photo", "destination", "photo.jpg", 1),
|
||||||
|
])
|
||||||
|
.unwrap();
|
||||||
|
let source = uid("source").to_string();
|
||||||
|
let destination = uid("destination").to_string();
|
||||||
|
let (move_id, _) = db
|
||||||
|
.enqueue_op(&PendingOp {
|
||||||
|
kind: OP_RENAME.to_string(),
|
||||||
|
uid: uid("photo").to_string(),
|
||||||
|
parent_uid: Some(destination.clone()),
|
||||||
|
name: Some("photo.jpg".into()),
|
||||||
|
blob_path: None,
|
||||||
|
meta_json: Some(
|
||||||
|
serde_json::to_string(&RenameMeta {
|
||||||
|
original_parent_uid: uid("nested").to_string(),
|
||||||
|
original_name: Some("photo.jpg".into()),
|
||||||
|
})
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
next_attempt_at: 20,
|
||||||
|
..bulk_op(0, &destination)
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
assert!(db.has_pending_moves_out_of(&source).unwrap());
|
||||||
|
assert!(!db.has_pending_moves_out_of(&destination).unwrap());
|
||||||
|
assert!(
|
||||||
|
!db.has_pending_moves_out_of(&uid("root").to_string())
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
let (trash_id, _) = db.replace_ops_with_trash(&source, "source", 2).unwrap();
|
||||||
|
|
||||||
|
assert!(db.claim_next_due_op(10).unwrap().is_none());
|
||||||
|
assert_eq!(db.earliest_due_at().unwrap(), Some(20));
|
||||||
|
assert_eq!(db.claim_next_due_op(20).unwrap().unwrap().id, move_id);
|
||||||
|
assert!(db.claim_next_due_op(20).unwrap().is_none());
|
||||||
|
assert_eq!(db.earliest_due_at().unwrap(), None);
|
||||||
|
db.delete_op(move_id).unwrap();
|
||||||
|
assert_eq!(db.claim_next_due_op(20).unwrap().unwrap().id, trash_id);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn claims_do_not_survive_the_process_that_took_them() {
|
fn claims_do_not_survive_the_process_that_took_them() {
|
||||||
let db = Db::open_in_memory().unwrap();
|
let db = Db::open_in_memory().unwrap();
|
||||||
@@ -7098,6 +7169,29 @@ fn a_raw_and_its_jpeg_are_one_entry_in_the_grid() {
|
|||||||
["jpeg", "raw"]
|
["jpeg", "raw"]
|
||||||
);
|
);
|
||||||
assert_eq!(db.photos_group("alone").unwrap().len(), 1);
|
assert_eq!(db.photos_group("alone").unwrap().len(), 1);
|
||||||
|
|
||||||
|
let hidden = db
|
||||||
|
.photo_group_members_for(&["raw".to_owned()].into_iter().collect())
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
hidden,
|
||||||
|
["raw".to_owned(), "jpeg".to_owned()].into_iter().collect()
|
||||||
|
);
|
||||||
|
let excluded = serde_json::to_string(&hidden).unwrap();
|
||||||
|
assert_eq!(db.photos_counts_visible(&excluded).unwrap(), (1, 0, 0));
|
||||||
|
let months = db.photos_months_visible(None, &excluded).unwrap();
|
||||||
|
assert_eq!(months.len(), 1);
|
||||||
|
assert_eq!(months[0].2, 1);
|
||||||
|
let public = db
|
||||||
|
.photos_page_visible(0, 1, None, None, false, false, &excluded)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
public
|
||||||
|
.iter()
|
||||||
|
.map(|photo| photo.uid.as_str())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
["alone"]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pixel names the two files of one raw capture after the role each plays, so
|
/// Pixel names the two files of one raw capture after the role each plays, so
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ pdfs-core.workspace = true
|
|||||||
zip.workspace = true
|
zip.workspace = true
|
||||||
sha1.workspace = true
|
sha1.workspace = true
|
||||||
proton-drive-rs.workspace = true
|
proton-drive-rs.workspace = true
|
||||||
|
pg-app.workspace = true
|
||||||
|
pg-core.workspace = true
|
||||||
|
hyper = { version = "1", features = ["http1", "server"] }
|
||||||
|
hyper-util = { version = "0.1", features = ["tokio"] }
|
||||||
|
http-body-util = "0.1"
|
||||||
|
getrandom = "0.4"
|
||||||
|
zeroize.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ impl Core {
|
|||||||
album: &NodeUid,
|
album: &NodeUid,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
excluded: &str,
|
||||||
) -> CoreResult<Vec<PhotoItem>> {
|
) -> CoreResult<Vec<PhotoItem>> {
|
||||||
let key = album.to_string();
|
let key = album.to_string();
|
||||||
let stamp = format!("{ALBUM_SYNCED_PREFIX}{key}");
|
let stamp = format!("{ALBUM_SYNCED_PREFIX}{key}");
|
||||||
@@ -172,7 +173,7 @@ impl Core {
|
|||||||
|
|
||||||
let page = self
|
let page = self
|
||||||
.db
|
.db
|
||||||
.album_photos_page(&key, offset, limit)
|
.album_photos_page_visible(&key, offset, limit, excluded)
|
||||||
.map_err(CoreError::from)?;
|
.map_err(CoreError::from)?;
|
||||||
Ok(page.into_iter().map(|p| self.photo_item(p)).collect())
|
Ok(page.into_iter().map(|p| self.photo_item(p)).collect())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -396,6 +396,11 @@ fn touched_topics(request: &CtlRequest) -> &'static [Topic] {
|
|||||||
use CtlRequest as R;
|
use CtlRequest as R;
|
||||||
match request {
|
match request {
|
||||||
R::Pin { .. } | R::Unpin { .. } => &[Topic::Files],
|
R::Pin { .. } | R::Unpin { .. } => &[Topic::Files],
|
||||||
|
R::DriveGallery {
|
||||||
|
action:
|
||||||
|
pdfs_core::control::GalleryAction::Lock
|
||||||
|
| pdfs_core::control::GalleryAction::Unlock { .. },
|
||||||
|
} => &[Topic::GalleryVisibility],
|
||||||
R::CreateAlbum { .. }
|
R::CreateAlbum { .. }
|
||||||
| R::RenameAlbum { .. }
|
| R::RenameAlbum { .. }
|
||||||
| R::DeleteAlbum { .. }
|
| R::DeleteAlbum { .. }
|
||||||
@@ -552,6 +557,33 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
// Registered before the request is even parsed, so a handler that wedges
|
// Registered before the request is even parsed, so a handler that wedges
|
||||||
// inside the daemon shows up by name in `pdfs diagnostics`.
|
// inside the daemon shows up by name in `pdfs diagnostics`.
|
||||||
let _inflight = super::diagnostics::InflightGuard::new(super::diagnostics::request_kind(&line));
|
let _inflight = super::diagnostics::InflightGuard::new(super::diagnostics::request_kind(&line));
|
||||||
|
let visibility = if matches!(
|
||||||
|
&request,
|
||||||
|
Ok(CtlRequest::PhotosTimeline { .. }
|
||||||
|
| CtlRequest::PhotoDuplicates
|
||||||
|
| CtlRequest::PhotoSimilar
|
||||||
|
| CtlRequest::PhotoPlaces
|
||||||
|
| CtlRequest::PlacePhotos { .. }
|
||||||
|
| CtlRequest::PlaceLocations { .. }
|
||||||
|
| CtlRequest::PhotosOnThisDay { .. }
|
||||||
|
| CtlRequest::PhotoGroup { .. }
|
||||||
|
| CtlRequest::PhotoAlbums
|
||||||
|
| CtlRequest::AlbumPhotos { .. }
|
||||||
|
| CtlRequest::PhotoMonths { .. }
|
||||||
|
| CtlRequest::PhotoThumbs { .. }
|
||||||
|
| CtlRequest::OpenGalleryImage { .. }
|
||||||
|
| CtlRequest::OpenPhoto { .. })
|
||||||
|
) {
|
||||||
|
core.gallery_visibility()
|
||||||
|
} else {
|
||||||
|
Ok(std::sync::Arc::default())
|
||||||
|
};
|
||||||
|
let visibility = match visibility {
|
||||||
|
Ok(visibility) => visibility,
|
||||||
|
Err(error) => return write_response(stream, CtlResponse::error(error)),
|
||||||
|
};
|
||||||
|
let excluded =
|
||||||
|
serde_json::to_string(&visibility.media).expect("a set of file identifiers serializes");
|
||||||
let response = match request {
|
let response = match request {
|
||||||
Ok(CtlRequest::Status) => status_response(core, username, mountpoint),
|
Ok(CtlRequest::Status) => status_response(core, username, mountpoint),
|
||||||
Ok(CtlRequest::Subscribe) => {
|
Ok(CtlRequest::Subscribe) => {
|
||||||
@@ -668,11 +700,12 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
range,
|
range,
|
||||||
favorites,
|
favorites,
|
||||||
not_in_album,
|
not_in_album,
|
||||||
|
&excluded,
|
||||||
) {
|
) {
|
||||||
Ok(Some(items)) => CtlResponse::Photos {
|
Ok(Some(items)) => CtlResponse::Photos {
|
||||||
available: true,
|
available: true,
|
||||||
items,
|
items,
|
||||||
counts: core.db.photos_counts().ok(),
|
counts: core.db.photos_counts_visible(&excluded).ok(),
|
||||||
},
|
},
|
||||||
Ok(None) => CtlResponse::Photos {
|
Ok(None) => CtlResponse::Photos {
|
||||||
available: false,
|
available: false,
|
||||||
@@ -693,7 +726,7 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
},
|
},
|
||||||
Err(e) => CtlResponse::error(e),
|
Err(e) => CtlResponse::error(e),
|
||||||
},
|
},
|
||||||
Ok(CtlRequest::PhotoPlaces) => match core.photo_places() {
|
Ok(CtlRequest::PhotoPlaces) => match core.photo_places(&excluded) {
|
||||||
Ok(items) => CtlResponse::Places {
|
Ok(items) => CtlResponse::Places {
|
||||||
items,
|
items,
|
||||||
mapping: core.timeline_progress(),
|
mapping: core.timeline_progress(),
|
||||||
@@ -701,7 +734,7 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
Err(e) => CtlResponse::error(e),
|
Err(e) => CtlResponse::error(e),
|
||||||
},
|
},
|
||||||
Ok(CtlRequest::PlacePhotos { id, offset, limit }) => {
|
Ok(CtlRequest::PlacePhotos { id, offset, limit }) => {
|
||||||
match core.place_photos(id, offset, clamp_limit(limit)) {
|
match core.place_photos(id, offset, clamp_limit(limit), &excluded) {
|
||||||
Ok(items) => CtlResponse::Photos {
|
Ok(items) => CtlResponse::Photos {
|
||||||
available: true,
|
available: true,
|
||||||
items,
|
items,
|
||||||
@@ -715,7 +748,7 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
Err(e) => CtlResponse::error(e),
|
Err(e) => CtlResponse::error(e),
|
||||||
},
|
},
|
||||||
Ok(CtlRequest::PhotosOnThisDay { limit }) => {
|
Ok(CtlRequest::PhotosOnThisDay { limit }) => {
|
||||||
match core.photos_on_this_day(clamp_limit(limit)) {
|
match core.photos_on_this_day(clamp_limit(limit), &excluded) {
|
||||||
Ok(items) => CtlResponse::Photos {
|
Ok(items) => CtlResponse::Photos {
|
||||||
available: true,
|
available: true,
|
||||||
items,
|
items,
|
||||||
@@ -760,7 +793,10 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
// An album page is a timeline page as far as the front-end is
|
// An album page is a timeline page as far as the front-end is
|
||||||
// concerned, so it comes back in the same reply — with `counts`
|
// concerned, so it comes back in the same reply — with `counts`
|
||||||
// unset, which describe the whole timeline rather than this album.
|
// unset, which describe the whole timeline rather than this album.
|
||||||
Some(album) => match core.album_photos(&album, offset, clamp_limit(limit)) {
|
Some(album) => match visibility
|
||||||
|
.permits(&uid)
|
||||||
|
.and_then(|()| core.album_photos(&album, offset, clamp_limit(limit), &excluded))
|
||||||
|
{
|
||||||
Ok(items) => CtlResponse::Photos {
|
Ok(items) => CtlResponse::Photos {
|
||||||
available: true,
|
available: true,
|
||||||
items,
|
items,
|
||||||
@@ -802,17 +838,23 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
core.remove_from_album(album, photos)
|
core.remove_from_album(album, photos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Ok(CtlRequest::PhotoMonths { kind }) => match core.db.photos_months(kind) {
|
Ok(CtlRequest::PhotoMonths { kind }) => {
|
||||||
Ok(months) => CtlResponse::PhotoMonths {
|
match core.db.photos_months_visible(kind, &excluded) {
|
||||||
months: months
|
Ok(months) => CtlResponse::PhotoMonths {
|
||||||
.into_iter()
|
months: months
|
||||||
.map(|(year, month, count)| PhotoMonth { year, month, count })
|
.into_iter()
|
||||||
.collect(),
|
.map(|(year, month, count)| PhotoMonth { year, month, count })
|
||||||
},
|
.collect(),
|
||||||
Err(e) => CtlResponse::error(e.into()),
|
},
|
||||||
},
|
Err(e) => CtlResponse::error(e.into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(CtlRequest::PhotoThumbs { uids }) => {
|
Ok(CtlRequest::PhotoThumbs { uids }) => {
|
||||||
let parsed: Vec<NodeUid> = uids.iter().filter_map(|u| parse_uid(u)).collect();
|
let parsed: Vec<NodeUid> = uids
|
||||||
|
.iter()
|
||||||
|
.filter(|uid| !visibility.media.contains(*uid))
|
||||||
|
.filter_map(|u| parse_uid(u))
|
||||||
|
.collect();
|
||||||
CtlResponse::Thumbs {
|
CtlResponse::Thumbs {
|
||||||
items: core.photo_thumbs(&parsed),
|
items: core.photo_thumbs(&parsed),
|
||||||
}
|
}
|
||||||
@@ -862,7 +904,7 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
running: core.timeline_refreshing(),
|
running: core.timeline_refreshing(),
|
||||||
},
|
},
|
||||||
Ok(CtlRequest::OpenPhoto { uid }) => match parse_uid(&uid) {
|
Ok(CtlRequest::OpenPhoto { uid }) => match parse_uid(&uid) {
|
||||||
Some(u) => match core.open_photo(&u) {
|
Some(u) => match visibility.permits(&uid).and_then(|()| core.open_photo(&u)) {
|
||||||
Ok(p) => CtlResponse::FilePath {
|
Ok(p) => CtlResponse::FilePath {
|
||||||
path: p.display().to_string(),
|
path: p.display().to_string(),
|
||||||
},
|
},
|
||||||
@@ -870,6 +912,27 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
},
|
},
|
||||||
None => CtlResponse::error(CoreError::invalid(format!("bad uid: {uid}"))),
|
None => CtlResponse::error(CoreError::invalid(format!("bad uid: {uid}"))),
|
||||||
},
|
},
|
||||||
|
Ok(CtlRequest::DriveGallery { action }) => core
|
||||||
|
.drive_gallery(action)
|
||||||
|
.unwrap_or_else(CtlResponse::error),
|
||||||
|
Ok(CtlRequest::OpenGalleryVideo { uid }) => core
|
||||||
|
.open_gallery_video(&uid)
|
||||||
|
.unwrap_or_else(CtlResponse::error),
|
||||||
|
Ok(CtlRequest::OpenGalleryImage { uid }) => match visibility
|
||||||
|
.permits(&uid)
|
||||||
|
.and_then(|()| core.open_shared_file(&uid))
|
||||||
|
{
|
||||||
|
Ok(path) => CtlResponse::FilePath {
|
||||||
|
path: path.display().to_string(),
|
||||||
|
},
|
||||||
|
Err(error) => CtlResponse::error(error),
|
||||||
|
},
|
||||||
|
Ok(CtlRequest::CloseGalleryVideo { token }) => core
|
||||||
|
.close_gallery_video(&token)
|
||||||
|
.unwrap_or_else(CtlResponse::error),
|
||||||
|
Ok(CtlRequest::GalleryThumbnail { uid }) => core
|
||||||
|
.gallery_thumbnail(&uid)
|
||||||
|
.unwrap_or_else(CtlResponse::error),
|
||||||
// The scan alone walks every archive's central directory, so even the
|
// The scan alone walks every archive's central directory, so even the
|
||||||
// dry run goes to a background thread and is read back through
|
// dry run goes to a background thread and is read back through
|
||||||
// `ImportStatus` rather than answered inline.
|
// `ImportStatus` rather than answered inline.
|
||||||
@@ -1929,9 +1992,14 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
// The request did not parse: the caller sent something malformed.
|
// The request did not parse: the caller sent something malformed.
|
||||||
Err(e) => CtlResponse::error(CoreError::invalid(format!("bad request: {e}"))),
|
Err(e) => CtlResponse::error(CoreError::invalid(format!("bad request: {e}"))),
|
||||||
};
|
};
|
||||||
|
let response = filter_gallery_response(response, &visibility);
|
||||||
if !touched.is_empty() && !matches!(response, CtlResponse::Error { .. }) {
|
if !touched.is_empty() && !matches!(response, CtlResponse::Error { .. }) {
|
||||||
core.events.publish(touched);
|
core.events.publish(touched);
|
||||||
}
|
}
|
||||||
|
write_response(stream, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_response(mut stream: UnixStream, response: CtlResponse) {
|
||||||
let mut out = match serde_json::to_vec(&response) {
|
let mut out = match serde_json::to_vec(&response) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -1940,10 +2008,40 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
out.push(b'\n');
|
out.push(b'\n');
|
||||||
let mut stream = stream;
|
|
||||||
let _ = stream.write_all(&out);
|
let _ = stream.write_all(&out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn filter_gallery_response(
|
||||||
|
mut response: CtlResponse,
|
||||||
|
visibility: &super::gallery::Visibility,
|
||||||
|
) -> CtlResponse {
|
||||||
|
let visible = |item: &pdfs_core::control::PhotoItem| !visibility.media.contains(&item.uid);
|
||||||
|
match &mut response {
|
||||||
|
CtlResponse::Photos { items, .. } => items.retain(visible),
|
||||||
|
CtlResponse::Albums { items, .. } => {
|
||||||
|
items.retain(|item| !visibility.albums.contains(&item.uid));
|
||||||
|
for album in items {
|
||||||
|
if album
|
||||||
|
.cover_uid
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|uid| visibility.media.contains(uid))
|
||||||
|
{
|
||||||
|
album.cover_uid = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CtlResponse::PhotoDuplicates { sets } | CtlResponse::PhotoSimilar { sets, .. } => {
|
||||||
|
for set in sets.iter_mut() {
|
||||||
|
set.retain(visible);
|
||||||
|
}
|
||||||
|
sets.retain(|set| set.len() > 1);
|
||||||
|
}
|
||||||
|
CtlResponse::PhotoLocations { items } => items.retain(|located| visible(&located.photo)),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
response
|
||||||
|
}
|
||||||
|
|
||||||
/// Listen on the control socket, serving one command per connection, each on its
|
/// Listen on the control socket, serving one command per connection, each on its
|
||||||
/// own thread. Runs on its own thread; returns only if the listener itself fails.
|
/// own thread. Runs on its own thread; returns only if the listener itself fails.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
//! are kept as a conflict copy rather than discarded — see
|
//! are kept as a conflict copy rather than discarded — see
|
||||||
//! [`Core::revision_conflict`].
|
//! [`Core::revision_conflict`].
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -53,6 +53,21 @@ use super::{
|
|||||||
use proton_drive_rs::proton_sdk::api::ResponseCode;
|
use proton_drive_rs::proton_sdk::api::ResponseCode;
|
||||||
use proton_drive_rs::proton_sdk::error::ProtonError;
|
use proton_drive_rs::proton_sdk::error::ProtonError;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct TrashedMove(String);
|
||||||
|
|
||||||
|
impl std::fmt::Display for TrashedMove {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"‘{}’ is in Proton Drive Trash. Restore it before retrying this move.",
|
||||||
|
self.0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for TrashedMove {}
|
||||||
|
|
||||||
const DRAIN_ACCESS_RECHECK: Duration = Duration::from_secs(5);
|
const DRAIN_ACCESS_RECHECK: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
/// How long an op may stay access-deferred before the deferral is reported as a
|
/// How long an op may stay access-deferred before the deferral is reported as a
|
||||||
@@ -795,13 +810,13 @@ impl Core {
|
|||||||
let parent = parse_node_uid(parent_str).ok_or("rename op has an unparseable parent")?;
|
let parent = parse_node_uid(parent_str).ok_or("rename op has an unparseable parent")?;
|
||||||
let name = op.name.clone().ok_or("rename op has no name")?;
|
let name = op.name.clone().ok_or("rename op has no name")?;
|
||||||
|
|
||||||
// The node we were asked to rename may be gone or trashed by now. Either
|
// A trashed node can be restored. Only retire the operation if the node
|
||||||
// way there is nothing to rename and nothing to lose — a rename holds no
|
// is gone entirely.
|
||||||
// bytes — so the op is satisfied rather than retried forever.
|
|
||||||
let node = match self.fetch_node_remote(&uid)? {
|
let node = match self.fetch_node_remote(&uid)? {
|
||||||
Some(n) if !n.trashed => n,
|
Some(n) if n.trashed => return Err(TrashedMove(n.name).into()),
|
||||||
_ => {
|
Some(n) => n,
|
||||||
warn!(%uid, name, "renamed node is gone or trashed remotely; dropping the rename");
|
None => {
|
||||||
|
warn!(%uid, name, "renamed node is gone remotely; dropping the rename");
|
||||||
self.db.delete_op(op.id)?;
|
self.db.delete_op(op.id)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -827,23 +842,38 @@ impl Core {
|
|||||||
// no window for the requirements to go stale between two calls —
|
// no window for the requirements to go stale between two calls —
|
||||||
// the race B46 queued this op to get away from.
|
// the race B46 queued this op to get away from.
|
||||||
let target = (node.name != name).then_some(name.as_str());
|
let target = (node.name != name).then_some(name.as_str());
|
||||||
match self.move_rename_remote(&uid, &parent, target) {
|
let try_move = |target| {
|
||||||
|
self.move_rename_remote(&uid, &parent, target).map_err(
|
||||||
|
|error| -> Box<dyn std::error::Error> {
|
||||||
|
if (is_gone(&error) || refusal(&error) == Some(Some(SyncIssue::Access)))
|
||||||
|
&& let Some(name) = trashed_move_folder(
|
||||||
|
node.parent_uid.iter().chain(std::iter::once(&parent)),
|
||||||
|
|uid| self.fetch_node_remote(uid).ok().flatten(),
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TrashedMove(name).into();
|
||||||
|
}
|
||||||
|
error.into()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
};
|
||||||
|
match try_move(target) {
|
||||||
Ok(()) => name.clone(),
|
Ok(()) => name.clone(),
|
||||||
// The destination holds that name already. Landing under a
|
// The destination holds that name already. Landing under a
|
||||||
// *different* name is the non-destructive resolution: it neither
|
// *different* name is the non-destructive resolution: it neither
|
||||||
// clobbers their file nor drops ours, and it is visible.
|
// clobbers their file nor drops ours, and it is visible.
|
||||||
Err(e) if is_already_exists(&e) => {
|
Err(e) if is_already_exists(e.as_ref()) => {
|
||||||
if self.name_is_held(op, Some(&parent), &name)? {
|
if self.name_is_held(op, Some(&parent), &name)? {
|
||||||
return Err(held_by_queued_change(&name));
|
return Err(held_by_queued_change(&name));
|
||||||
}
|
}
|
||||||
// What held it may have let go since Drive answered
|
// What held it may have let go since Drive answered
|
||||||
// (docs/BUGS.md B144).
|
// (docs/BUGS.md B144).
|
||||||
match self.move_rename_remote(&uid, &parent, target) {
|
match try_move(target) {
|
||||||
Ok(()) => name.clone(),
|
Ok(()) => name.clone(),
|
||||||
Err(e) if is_already_exists(&e) => {
|
Err(e) if is_already_exists(e.as_ref()) => {
|
||||||
let alt = conflict_name(&name, now_secs());
|
let alt = conflict_name(&name, now_secs());
|
||||||
warn!(%uid, name, alt, "destination already holds that name; using a conflict name");
|
warn!(%uid, name, alt, "destination already holds that name; using a conflict name");
|
||||||
self.move_rename_remote(&uid, &parent, Some(&alt))?;
|
try_move(Some(&alt))?;
|
||||||
self.adopt_drained_name(&uid, &alt);
|
self.adopt_drained_name(&uid, &alt);
|
||||||
self.log_activity(
|
self.log_activity(
|
||||||
ActivityKind::Rename,
|
ActivityKind::Rename,
|
||||||
@@ -853,7 +883,7 @@ impl Core {
|
|||||||
);
|
);
|
||||||
alt
|
alt
|
||||||
}
|
}
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => return Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The destination folder is gone. Leaving the node in its current
|
// The destination folder is gone. Leaving the node in its current
|
||||||
@@ -862,7 +892,7 @@ impl Core {
|
|||||||
// the user chose still applies there. Retrying the move could
|
// the user chose still applies there. Retrying the move could
|
||||||
// only fail again — the folder is not coming back — and would
|
// only fail again — the folder is not coming back — and would
|
||||||
// wedge the queue.
|
// wedge the queue.
|
||||||
Err(e) if is_gone(&e) => {
|
Err(e) if is_gone(e.as_ref()) => {
|
||||||
warn!(%uid, name, %parent, "move destination is gone; leaving the node where it is");
|
warn!(%uid, name, %parent, "move destination is gone; leaving the node where it is");
|
||||||
let landed = match self.drain_rename_in_place(
|
let landed = match self.drain_rename_in_place(
|
||||||
op,
|
op,
|
||||||
@@ -885,7 +915,7 @@ impl Core {
|
|||||||
);
|
);
|
||||||
landed
|
landed
|
||||||
}
|
}
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => return Err(e),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.db.delete_op(op.id)?;
|
self.db.delete_op(op.id)?;
|
||||||
@@ -1349,7 +1379,11 @@ impl Core {
|
|||||||
parent: Option<&NodeUid>,
|
parent: Option<&NodeUid>,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||||
if self.db.has_pending_trash_named(name)? {
|
let parent_uid = parent.map(NodeUid::to_string);
|
||||||
|
if self
|
||||||
|
.db
|
||||||
|
.has_pending_trash_named(name, parent_uid.as_deref())?
|
||||||
|
{
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
if op.attempts >= NAME_HOLD_ATTEMPTS {
|
if op.attempts >= NAME_HOLD_ATTEMPTS {
|
||||||
@@ -2695,6 +2729,29 @@ fn moved_elsewhere(meta: &RenameMeta, node: &Node, parent: &NodeUid, name: &str)
|
|||||||
!at(&meta.original_parent_uid, original_name) && !at(&parent.to_string(), name)
|
!at(&meta.original_parent_uid, original_name) && !at(&parent.to_string(), name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A child can have a normal metadata record even when an ancestor is trashed.
|
||||||
|
/// Check both live parent chains before interpreting a refused move as an
|
||||||
|
/// access problem. Shared ancestors only need to be fetched once.
|
||||||
|
fn trashed_move_folder<'a>(
|
||||||
|
parents: impl IntoIterator<Item = &'a NodeUid>,
|
||||||
|
mut fetch: impl FnMut(&NodeUid) -> Option<Node>,
|
||||||
|
) -> Option<String> {
|
||||||
|
let mut seen = HashSet::new();
|
||||||
|
for parent in parents {
|
||||||
|
let mut next = Some(parent.clone());
|
||||||
|
while let Some(uid) = next.take()
|
||||||
|
&& seen.insert(uid.clone())
|
||||||
|
&& let Some(node) = fetch(&uid)
|
||||||
|
{
|
||||||
|
if node.trashed {
|
||||||
|
return Some(node.name);
|
||||||
|
}
|
||||||
|
next = node.parent_uid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
/// The answer from Drive somewhere in `e`'s chain, if it got that far.
|
/// The answer from Drive somewhere in `e`'s chain, if it got that far.
|
||||||
fn proton_error<'e>(e: &'e (dyn std::error::Error + 'static)) -> Option<&'e ProtonError> {
|
fn proton_error<'e>(e: &'e (dyn std::error::Error + 'static)) -> Option<&'e ProtonError> {
|
||||||
std::iter::successors(Some(e), |e| e.source()).find_map(|e| e.downcast_ref::<ProtonError>())
|
std::iter::successors(Some(e), |e| e.source()).find_map(|e| e.downcast_ref::<ProtonError>())
|
||||||
@@ -2704,6 +2761,9 @@ fn proton_error<'e>(e: &'e (dyn std::error::Error + 'static)) -> Option<&'e Prot
|
|||||||
/// could not be reached, which says nothing; otherwise the issue Drive's answer
|
/// could not be reached, which says nothing; otherwise the issue Drive's answer
|
||||||
/// is, or `Some(None)` for a failure that is not a refusal.
|
/// is, or `Some(None)` for a failure that is not a refusal.
|
||||||
fn refusal(e: &(dyn std::error::Error + 'static)) -> Option<Option<SyncIssue>> {
|
fn refusal(e: &(dyn std::error::Error + 'static)) -> Option<Option<SyncIssue>> {
|
||||||
|
if e.is::<TrashedMove>() {
|
||||||
|
return Some(Some(SyncIssue::Trashed));
|
||||||
|
}
|
||||||
let proton = proton_error(e)?;
|
let proton = proton_error(e)?;
|
||||||
// A refused session refuses everything, so it says nothing about this
|
// A refused session refuses everything, so it says nothing about this
|
||||||
// op either; the mount is offline for it (`Core::lost_link`).
|
// op either; the mount is offline for it (`Core::lost_link`).
|
||||||
@@ -3111,6 +3171,31 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_refused_move_identifies_a_trashed_ancestor_on_either_side() {
|
||||||
|
let source = folder_node("source", Some("old"));
|
||||||
|
let destination = folder_node("destination", Some("new"));
|
||||||
|
let mut old = folder_node("old", None);
|
||||||
|
let mut new = folder_node("new", None);
|
||||||
|
let find = |old: &Node, new: &Node| {
|
||||||
|
trashed_move_folder([&source.uid, &destination.uid], |uid| {
|
||||||
|
[&source, &destination, old, new]
|
||||||
|
.into_iter()
|
||||||
|
.find(|node| node.uid == *uid)
|
||||||
|
.cloned()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
old.trashed = true;
|
||||||
|
assert_eq!(find(&old, &new).as_deref(), Some("old"));
|
||||||
|
old.trashed = false;
|
||||||
|
new.trashed = true;
|
||||||
|
let error = TrashedMove(find(&old, &new).unwrap());
|
||||||
|
assert_eq!(refusal(&error), Some(Some(SyncIssue::Trashed)));
|
||||||
|
assert!(error.to_string().contains("‘new’"));
|
||||||
|
new.trashed = false;
|
||||||
|
assert_eq!(find(&old, &new), None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn queued_cross_parent_rename_retains_viewer_source_authority_after_local_move() {
|
fn queued_cross_parent_rename_retains_viewer_source_authority_after_local_move() {
|
||||||
use std::sync::atomic::{AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
|
|||||||
@@ -2372,17 +2372,19 @@ impl ProtonFs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Offline: queue it. Trashing is the one mutation a user expects to work
|
// Queue a folder trash while Drive still holds children that were moved
|
||||||
// regardless — the file is gone from their point of view the moment the
|
// out locally. The drain waits for those moves before sending it.
|
||||||
// command returns. The same when the network goes
|
|
||||||
// away under the remote call below.
|
|
||||||
let queue_it = |reply: ReplyEmpty| match self.core.queue_trash(&uid, name, open_now) {
|
let queue_it = |reply: ReplyEmpty| match self.core.queue_trash(&uid, name, open_now) {
|
||||||
Ok(()) => reply.ok(),
|
Ok(()) => reply.ok(),
|
||||||
Err(e) => reply.error(e),
|
Err(e) => reply.error(e),
|
||||||
};
|
};
|
||||||
if !self.core.sends_inline() {
|
if !self.core.sends_inline() {
|
||||||
queue_it(reply);
|
return queue_it(reply);
|
||||||
return;
|
}
|
||||||
|
match self.core.has_pending_moves_out_of(&uid) {
|
||||||
|
Ok(false) => {}
|
||||||
|
Ok(true) => return queue_it(reply),
|
||||||
|
Err(error) => return reply.error(error),
|
||||||
}
|
}
|
||||||
if let Err(e) = self.core.require_uid_writable(&uid) {
|
if let Err(e) = self.core.require_uid_writable(&uid) {
|
||||||
reply.error(e);
|
reply.error(e);
|
||||||
|
|||||||
@@ -0,0 +1,431 @@
|
|||||||
|
//! Host Proton Gallery's account and catalog services in the Drive daemon.
|
||||||
|
|
||||||
|
mod video;
|
||||||
|
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::{
|
||||||
|
Arc,
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
};
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
use pdfs_core::control::{
|
||||||
|
GalleryAction, GalleryAlbum, GalleryFolder, GalleryPlace, PhotoItem, PhotoKind, Response,
|
||||||
|
};
|
||||||
|
use pdfs_core::{CoreError, CoreResult};
|
||||||
|
use pg_app::{App, View};
|
||||||
|
use pg_core::CancellationToken;
|
||||||
|
use pg_core::model::{AssetKey, SourceId};
|
||||||
|
use proton_drive_rs::proton_sdk::session::ProtonApiSession;
|
||||||
|
use tokio::sync::{Mutex, OnceCell};
|
||||||
|
|
||||||
|
use super::{Core, NodeUid, parse_uid};
|
||||||
|
|
||||||
|
pub(super) struct Gallery {
|
||||||
|
root: PathBuf,
|
||||||
|
session: ProtonApiSession,
|
||||||
|
cancel: CancellationToken,
|
||||||
|
app: OnceCell<App>,
|
||||||
|
checked: Mutex<Option<(Instant, Option<Arc<Visibility>>)>>,
|
||||||
|
unlocked: AtomicBool,
|
||||||
|
video: video::Server,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, PartialEq, Eq)]
|
||||||
|
pub(super) struct Visibility {
|
||||||
|
pub(super) media: HashSet<String>,
|
||||||
|
pub(super) albums: HashSet<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Visibility {
|
||||||
|
pub(super) fn permits(&self, uid: &str) -> CoreResult<()> {
|
||||||
|
if self.media.contains(uid) || self.albums.contains(uid) {
|
||||||
|
return Err(CoreError::invalid("Unlock hidden albums to open this item"));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Gallery {
|
||||||
|
pub(super) fn new(root: PathBuf, session: ProtonApiSession) -> Self {
|
||||||
|
Self {
|
||||||
|
root,
|
||||||
|
session,
|
||||||
|
cancel: CancellationToken::new(),
|
||||||
|
app: OnceCell::new(),
|
||||||
|
checked: Mutex::new(None),
|
||||||
|
unlocked: AtomicBool::new(false),
|
||||||
|
video: video::Server::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn cancel(&self) {
|
||||||
|
self.cancel.cancel();
|
||||||
|
self.video.close_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn app(&self, core: &Core) -> CoreResult<&App> {
|
||||||
|
self.app
|
||||||
|
.get_or_try_init(|| async {
|
||||||
|
App::open_hosted(
|
||||||
|
self.root.clone(),
|
||||||
|
self.session.clone(),
|
||||||
|
core.client.clone(),
|
||||||
|
self.cancel.child_token(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn ensure_visibility(
|
||||||
|
&self,
|
||||||
|
core: &Core,
|
||||||
|
app: &App,
|
||||||
|
force: bool,
|
||||||
|
) -> CoreResult<Arc<Visibility>> {
|
||||||
|
if self.cancel.is_cancelled() {
|
||||||
|
return Err(CoreError::remote("The Gallery session expired"));
|
||||||
|
}
|
||||||
|
let mut checked = self.checked.lock().await;
|
||||||
|
if !force
|
||||||
|
&& let Some((instant, Some(visibility))) = checked.as_ref()
|
||||||
|
&& instant.elapsed() < Duration::from_secs(60)
|
||||||
|
{
|
||||||
|
return Ok(visibility.clone());
|
||||||
|
}
|
||||||
|
let previous = checked.as_ref().map(|(_, visibility)| visibility.as_ref());
|
||||||
|
let visibility = async {
|
||||||
|
let account = self.account()?;
|
||||||
|
app.refresh_gallery_configuration(false)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
let mut visibility = Visibility::default();
|
||||||
|
for (volume, node) in app
|
||||||
|
.catalog
|
||||||
|
.hidden_assets(account.clone())
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?
|
||||||
|
{
|
||||||
|
visibility
|
||||||
|
.media
|
||||||
|
.insert(NodeUid::new(volume.into(), node.into()).to_string());
|
||||||
|
}
|
||||||
|
visibility.media.extend(
|
||||||
|
core.db
|
||||||
|
.photo_group_members_for(&visibility.media)
|
||||||
|
.map_err(CoreError::from)?,
|
||||||
|
);
|
||||||
|
for album in app
|
||||||
|
.catalog
|
||||||
|
.hidden_configuration_albums(account)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?
|
||||||
|
{
|
||||||
|
visibility.albums.insert(
|
||||||
|
NodeUid::new(album.volume.as_str().into(), album.node.as_str().into())
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok::<_, CoreError>(Arc::new(visibility))
|
||||||
|
}
|
||||||
|
.await;
|
||||||
|
let current = visibility.as_ref().ok();
|
||||||
|
if previous.is_some_and(|previous| previous != current) {
|
||||||
|
self.video.close_all();
|
||||||
|
core.events
|
||||||
|
.publish(&[pdfs_core::control::Topic::GalleryVisibilitySynced]);
|
||||||
|
}
|
||||||
|
*checked = Some((Instant::now(), current.cloned()));
|
||||||
|
visibility
|
||||||
|
}
|
||||||
|
|
||||||
|
fn account(&self) -> CoreResult<pg_core::model::AccountId> {
|
||||||
|
pg_core::model::AccountId::new(self.session.user_id().as_str()).map_err(gallery_error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lock(&self) {
|
||||||
|
self.unlocked.store(false, Ordering::SeqCst);
|
||||||
|
self.video.close_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unlocked(&self) -> bool {
|
||||||
|
self.unlocked.load(Ordering::SeqCst)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) async fn poll(self: Arc<Self>, core: Core) {
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
biased;
|
||||||
|
_ = self.cancel.cancelled() => break,
|
||||||
|
_ = tokio::time::sleep(Duration::from_secs(60)) => {}
|
||||||
|
}
|
||||||
|
if let Some(app) = self.app.get() {
|
||||||
|
let _ = self.ensure_visibility(&core, app, false).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn asset(&self, uid: &NodeUid) -> CoreResult<AssetKey> {
|
||||||
|
Ok(AssetKey {
|
||||||
|
account: self.account()?,
|
||||||
|
volume: pg_core::model::VolumeId::new(uid.volume_id.as_str()).map_err(gallery_error)?,
|
||||||
|
node: pg_core::model::NodeId::new(uid.link_id.as_str()).map_err(gallery_error)?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gallery_error(error: impl std::fmt::Display) -> CoreError {
|
||||||
|
CoreError::remote(error.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn uid(value: &str) -> CoreResult<NodeUid> {
|
||||||
|
parse_uid(value).ok_or_else(|| CoreError::invalid("Invalid gallery node"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn done() -> Response {
|
||||||
|
Response::Ok {
|
||||||
|
message: "Gallery updated".into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn asset_uid(asset: &AssetKey) -> String {
|
||||||
|
NodeUid::new(asset.volume.as_str().into(), asset.node.as_str().into()).to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Core {
|
||||||
|
pub(super) fn gallery_visibility(&self) -> CoreResult<Arc<Visibility>> {
|
||||||
|
if self.gallery.is_none() {
|
||||||
|
return Ok(Arc::default());
|
||||||
|
}
|
||||||
|
let gallery = self.gallery_host()?;
|
||||||
|
self.rt.block_on(async {
|
||||||
|
let app = gallery.app(self).await?;
|
||||||
|
let visibility = gallery.ensure_visibility(self, app, false).await?;
|
||||||
|
Ok(if gallery.unlocked() {
|
||||||
|
Arc::default()
|
||||||
|
} else {
|
||||||
|
visibility
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gallery_host(&self) -> CoreResult<&Gallery> {
|
||||||
|
self.gallery
|
||||||
|
.as_deref()
|
||||||
|
.filter(|gallery| !gallery.cancel.is_cancelled())
|
||||||
|
.ok_or_else(|| CoreError::remote("The Gallery session is unavailable"))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn drive_gallery(&self, action: GalleryAction) -> CoreResult<Response> {
|
||||||
|
let gallery = self.gallery_host()?;
|
||||||
|
let action = match action {
|
||||||
|
GalleryAction::Unlock { passphrase } => {
|
||||||
|
let passphrase = zeroize::Zeroizing::new(passphrase);
|
||||||
|
pdfs_core::auth::unlock_gallery(gallery.session.username(), &passphrase)
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
gallery.unlocked.store(true, Ordering::SeqCst);
|
||||||
|
return Ok(done());
|
||||||
|
}
|
||||||
|
GalleryAction::Lock => {
|
||||||
|
gallery.lock();
|
||||||
|
return Ok(done());
|
||||||
|
}
|
||||||
|
other => other,
|
||||||
|
};
|
||||||
|
self.rt.block_on(async {
|
||||||
|
let app = gallery.app(self).await?;
|
||||||
|
gallery
|
||||||
|
.ensure_visibility(self, app, matches!(action, GalleryAction::Refresh))
|
||||||
|
.await?;
|
||||||
|
let unlocked = gallery.unlocked();
|
||||||
|
match action {
|
||||||
|
GalleryAction::Unlock { .. } | GalleryAction::Lock => unreachable!(),
|
||||||
|
GalleryAction::List {
|
||||||
|
album,
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
} => {
|
||||||
|
let parent = album
|
||||||
|
.as_ref()
|
||||||
|
.map(|a| (a.gallery.as_str(), a.album.as_str()));
|
||||||
|
let albums = if offset == 0 {
|
||||||
|
app.drive_albums(parent, unlocked)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?
|
||||||
|
.into_iter()
|
||||||
|
.map(|entry| GalleryAlbum {
|
||||||
|
place: GalleryPlace {
|
||||||
|
gallery: entry.gallery.to_string(),
|
||||||
|
album: entry.source.id.to_string(),
|
||||||
|
},
|
||||||
|
folder: GalleryFolder {
|
||||||
|
uid: NodeUid::new(
|
||||||
|
entry.source.volume.as_str().into(),
|
||||||
|
entry.source.root.as_str().into(),
|
||||||
|
)
|
||||||
|
.to_string(),
|
||||||
|
name: entry.settings.title.unwrap_or(entry.source.label),
|
||||||
|
},
|
||||||
|
cover: entry.cover.map(|asset| asset_uid(&asset.key)),
|
||||||
|
items: entry.direct_items,
|
||||||
|
folders: entry.child_albums,
|
||||||
|
hidden: entry.settings.hidden,
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
} else {
|
||||||
|
Vec::new()
|
||||||
|
};
|
||||||
|
let (items, total) = if let Some(GalleryPlace { gallery, album }) = album {
|
||||||
|
let view = app
|
||||||
|
.outline_with_visibility(
|
||||||
|
View::DriveAlbum { gallery, album },
|
||||||
|
false,
|
||||||
|
unlocked,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
let total = view.len();
|
||||||
|
let items = app
|
||||||
|
.outline_items(&view, offset.min(total), limit.clamp(1, 250))
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.map(|item| PhotoItem {
|
||||||
|
uid: asset_uid(&item.key),
|
||||||
|
capture_time: item.sort_time,
|
||||||
|
thumb_path: None,
|
||||||
|
name: Some(item.name),
|
||||||
|
ratio: item.aspect_ratio,
|
||||||
|
no_thumb: false,
|
||||||
|
kind: if item.is_video {
|
||||||
|
PhotoKind::Video
|
||||||
|
} else {
|
||||||
|
PhotoKind::Photo
|
||||||
|
},
|
||||||
|
favorite: item.favorite,
|
||||||
|
group_size: 1,
|
||||||
|
has_raw: false,
|
||||||
|
place_id: None,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
(items, total)
|
||||||
|
} else {
|
||||||
|
(Vec::new(), 0)
|
||||||
|
};
|
||||||
|
Ok(Response::GalleryPage {
|
||||||
|
albums,
|
||||||
|
items,
|
||||||
|
total,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
GalleryAction::Folders { parent } => {
|
||||||
|
let list = app
|
||||||
|
.browse_drive_folders(parent.as_deref().map(uid).transpose()?)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
Ok(Response::GalleryFolders {
|
||||||
|
folders: list
|
||||||
|
.children
|
||||||
|
.into_iter()
|
||||||
|
.map(|folder| GalleryFolder {
|
||||||
|
uid: folder.uid.to_string(),
|
||||||
|
name: folder.name,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
GalleryAction::Add { uid: node } => {
|
||||||
|
app.add_drive_folder(uid(&node)?)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
gallery.ensure_visibility(self, app, true).await?;
|
||||||
|
Ok(done())
|
||||||
|
}
|
||||||
|
GalleryAction::Remove { gallery: id } => {
|
||||||
|
app.forget_drive_gallery(SourceId::new(id).map_err(gallery_error)?)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
gallery.ensure_visibility(self, app, true).await?;
|
||||||
|
Ok(done())
|
||||||
|
}
|
||||||
|
GalleryAction::Refresh => {
|
||||||
|
for album in app.drive_albums(None, true).await.map_err(gallery_error)? {
|
||||||
|
let root = NodeUid::new(
|
||||||
|
album.source.volume.as_str().into(),
|
||||||
|
album.source.root.as_str().into(),
|
||||||
|
);
|
||||||
|
app.scan_drive_folder(root).await.map_err(gallery_error)?;
|
||||||
|
}
|
||||||
|
gallery.ensure_visibility(self, app, true).await?;
|
||||||
|
Ok(done())
|
||||||
|
}
|
||||||
|
GalleryAction::Cover { album, uid: node } => {
|
||||||
|
let id = SourceId::new(&album.album).map_err(gallery_error)?;
|
||||||
|
app.outline(View::DriveAlbum {
|
||||||
|
gallery: album.gallery,
|
||||||
|
album: album.album,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
let mut settings = app
|
||||||
|
.catalog
|
||||||
|
.album_settings(id.clone())
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
settings.cover = Some(gallery.asset(&uid(&node)?)?);
|
||||||
|
app.catalog
|
||||||
|
.set_album_settings(id, settings)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
gallery.ensure_visibility(self, app, true).await?;
|
||||||
|
Ok(done())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn open_gallery_video(&self, node: &str) -> CoreResult<Response> {
|
||||||
|
let gallery = self.gallery_host()?;
|
||||||
|
let uid = uid(node)?;
|
||||||
|
self.rt.block_on(async {
|
||||||
|
let app = gallery.app(self).await?;
|
||||||
|
let visibility = gallery.ensure_visibility(self, app, false).await?;
|
||||||
|
if !gallery.unlocked() {
|
||||||
|
visibility.permits(node)?;
|
||||||
|
}
|
||||||
|
let stream = app
|
||||||
|
.stream_video(&gallery.asset(&uid)?)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?;
|
||||||
|
gallery.video.open(stream, &gallery.cancel).await
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn close_gallery_video(&self, token: &str) -> CoreResult<Response> {
|
||||||
|
self.gallery_host()?.video.close(token);
|
||||||
|
Ok(done())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn gallery_thumbnail(&self, node: &str) -> CoreResult<Response> {
|
||||||
|
use base64::{Engine, engine::general_purpose::STANDARD};
|
||||||
|
let gallery = self.gallery_host()?;
|
||||||
|
let asset = gallery.asset(&uid(node)?)?;
|
||||||
|
self.rt.block_on(async {
|
||||||
|
let app = gallery.app(self).await?;
|
||||||
|
let visibility = gallery.ensure_visibility(self, app, false).await?;
|
||||||
|
if !gallery.unlocked() {
|
||||||
|
visibility.permits(node)?;
|
||||||
|
}
|
||||||
|
let data = app
|
||||||
|
.thumbnail(&asset)
|
||||||
|
.await
|
||||||
|
.map_err(gallery_error)?
|
||||||
|
.map(|bytes| STANDARD.encode(bytes));
|
||||||
|
Ok(Response::GalleryThumbnail { data })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
use std::{collections::VecDeque, io, sync::Arc, time::Duration};
|
||||||
|
|
||||||
|
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||||
|
use http_body_util::{BodyExt, Empty, StreamBody, combinators::UnsyncBoxBody};
|
||||||
|
use hyper::{
|
||||||
|
Method, Request, Response, StatusCode,
|
||||||
|
body::{Bytes, Frame, Incoming},
|
||||||
|
header,
|
||||||
|
server::conn::http1,
|
||||||
|
service::service_fn,
|
||||||
|
};
|
||||||
|
use hyper_util::rt::TokioIo;
|
||||||
|
use pdfs_core::{CoreResult, control::Response as ControlResponse};
|
||||||
|
use pg_app::video::VideoStream;
|
||||||
|
use pg_core::CancellationToken;
|
||||||
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
|
type Body = UnsyncBoxBody<Bytes, io::Error>;
|
||||||
|
|
||||||
|
const LEASE: Duration = Duration::from_secs(4 * 60 * 60);
|
||||||
|
const MAX_STREAMS: usize = 4;
|
||||||
|
const CHUNK: u32 = 256 * 1024;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub(super) struct Server {
|
||||||
|
active: parking_lot::Mutex<VecDeque<(String, CancellationToken)>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Server {
|
||||||
|
pub(super) fn close(&self, token: &str) {
|
||||||
|
let mut active = self.active.lock();
|
||||||
|
if let Some(index) = active.iter().position(|(id, _)| id == token)
|
||||||
|
&& let Some((_, cancel)) = active.remove(index)
|
||||||
|
{
|
||||||
|
cancel.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn close_all(&self) {
|
||||||
|
for (_, cancel) in self.active.lock().drain(..) {
|
||||||
|
cancel.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) async fn open(
|
||||||
|
&self,
|
||||||
|
stream: Arc<VideoStream>,
|
||||||
|
account: &CancellationToken,
|
||||||
|
) -> CoreResult<ControlResponse> {
|
||||||
|
let listener = TcpListener::bind((std::net::Ipv4Addr::LOCALHOST, 0))
|
||||||
|
.await
|
||||||
|
.map_err(super::gallery_error)?;
|
||||||
|
let address = listener.local_addr().map_err(super::gallery_error)?;
|
||||||
|
let mut nonce = [0; 32];
|
||||||
|
getrandom::fill(&mut nonce).map_err(super::gallery_error)?;
|
||||||
|
let token = URL_SAFE_NO_PAD.encode(nonce);
|
||||||
|
let path: Arc<str> = format!("/{token}").into();
|
||||||
|
let cancel = account.child_token();
|
||||||
|
{
|
||||||
|
let mut active = self.active.lock();
|
||||||
|
active.retain(|(_, cancel)| !cancel.is_cancelled());
|
||||||
|
if active.len() >= MAX_STREAMS
|
||||||
|
&& let Some((_, oldest)) = active.pop_front()
|
||||||
|
{
|
||||||
|
oldest.cancel();
|
||||||
|
}
|
||||||
|
active.push_back((token.clone(), cancel.clone()));
|
||||||
|
}
|
||||||
|
let size = stream.length();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut connections = tokio::task::JoinSet::new();
|
||||||
|
let lifetime = tokio::time::sleep(LEASE);
|
||||||
|
tokio::pin!(lifetime);
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
biased;
|
||||||
|
_ = cancel.cancelled() => break,
|
||||||
|
_ = &mut lifetime => break,
|
||||||
|
_ = connections.join_next(), if !connections.is_empty() => {},
|
||||||
|
incoming = listener.accept(), if connections.len() < 8 => {
|
||||||
|
let Ok((socket, _)) = incoming else { break };
|
||||||
|
let stream = stream.clone();
|
||||||
|
let path = path.clone();
|
||||||
|
connections.spawn(async move {
|
||||||
|
let service = service_fn(move |request| reply(request, stream.clone(), path.clone()));
|
||||||
|
let _ = http1::Builder::new()
|
||||||
|
.timer(hyper_util::rt::TokioTimer::new())
|
||||||
|
.header_read_timeout(Duration::from_secs(10))
|
||||||
|
.keep_alive(false)
|
||||||
|
.serve_connection(TokioIo::new(socket), service).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stream.stop();
|
||||||
|
cancel.cancel();
|
||||||
|
connections.abort_all();
|
||||||
|
});
|
||||||
|
Ok(ControlResponse::GalleryVideo {
|
||||||
|
url: format!("http://{address}/{token}"),
|
||||||
|
token,
|
||||||
|
size,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn range(value: Option<&str>, size: u64) -> Option<(u64, u64)> {
|
||||||
|
let Some(value) = value else {
|
||||||
|
return Some((0, size));
|
||||||
|
};
|
||||||
|
let (first, last) = value.strip_prefix("bytes=")?.split_once('-')?;
|
||||||
|
if first.is_empty() {
|
||||||
|
let suffix = last.parse::<u64>().ok()?.min(size);
|
||||||
|
return (suffix > 0).then_some((size - suffix, size));
|
||||||
|
}
|
||||||
|
let start = first.parse::<u64>().ok()?;
|
||||||
|
let end = if last.is_empty() {
|
||||||
|
size
|
||||||
|
} else {
|
||||||
|
last.parse::<u64>().ok()?.saturating_add(1).min(size)
|
||||||
|
};
|
||||||
|
(start < end).then_some((start, end))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn empty() -> Body {
|
||||||
|
Empty::new().map_err(|never| match never {}).boxed_unsync()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn reply(
|
||||||
|
request: Request<Incoming>,
|
||||||
|
stream: Arc<VideoStream>,
|
||||||
|
path: Arc<str>,
|
||||||
|
) -> Result<Response<Body>, hyper::http::Error> {
|
||||||
|
let response = Response::builder().header(header::CACHE_CONTROL, "no-store");
|
||||||
|
if request
|
||||||
|
.uri()
|
||||||
|
.path_and_query()
|
||||||
|
.is_none_or(|actual| actual.as_str() != path.as_ref())
|
||||||
|
{
|
||||||
|
return response.status(StatusCode::NOT_FOUND).body(empty());
|
||||||
|
}
|
||||||
|
if !matches!(*request.method(), Method::HEAD | Method::GET) {
|
||||||
|
return response
|
||||||
|
.status(StatusCode::METHOD_NOT_ALLOWED)
|
||||||
|
.body(empty());
|
||||||
|
}
|
||||||
|
let size = stream.length();
|
||||||
|
let requested = request.headers().get(header::RANGE);
|
||||||
|
let parsed = match requested {
|
||||||
|
Some(value) => value
|
||||||
|
.to_str()
|
||||||
|
.ok()
|
||||||
|
.and_then(|value| range(Some(value), size)),
|
||||||
|
None => range(None, size),
|
||||||
|
};
|
||||||
|
let Some((start, end)) = parsed else {
|
||||||
|
return response
|
||||||
|
.status(StatusCode::RANGE_NOT_SATISFIABLE)
|
||||||
|
.header(header::CONTENT_RANGE, format!("bytes */{size}"))
|
||||||
|
.body(empty());
|
||||||
|
};
|
||||||
|
let response = response
|
||||||
|
.header(header::ACCEPT_RANGES, "bytes")
|
||||||
|
.header(header::CONTENT_LENGTH, end - start)
|
||||||
|
.header(header::CONTENT_TYPE, "application/octet-stream");
|
||||||
|
let response = if requested.is_some() {
|
||||||
|
response.status(StatusCode::PARTIAL_CONTENT).header(
|
||||||
|
header::CONTENT_RANGE,
|
||||||
|
format!("bytes {start}-{}/{size}", end - 1),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
response
|
||||||
|
};
|
||||||
|
if request.method() == Method::HEAD {
|
||||||
|
return response.body(empty());
|
||||||
|
}
|
||||||
|
let body = futures::stream::try_unfold((stream, start), move |(stream, at)| async move {
|
||||||
|
if at == end {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
let read = (end - at).min(u64::from(CHUNK)) as u32;
|
||||||
|
let bytes = stream.read(at, read).await.map_err(io::Error::other)?;
|
||||||
|
if bytes.is_empty() {
|
||||||
|
return Err(io::Error::from(io::ErrorKind::UnexpectedEof));
|
||||||
|
}
|
||||||
|
let next = at + bytes.len() as u64;
|
||||||
|
Ok(Some((Frame::data(Bytes::from(bytes)), (stream, next))))
|
||||||
|
});
|
||||||
|
response.body(BodyExt::boxed_unsync(StreamBody::new(body)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::range;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn resolves_seek_ranges_and_rejects_invalid_ranges() {
|
||||||
|
assert_eq!(range(None, 10), Some((0, 10)));
|
||||||
|
assert_eq!(range(Some("bytes=3-5"), 10), Some((3, 6)));
|
||||||
|
assert_eq!(range(Some("bytes=9-"), 10), Some((9, 10)));
|
||||||
|
assert_eq!(range(Some("bytes=-3"), 10), Some((7, 10)));
|
||||||
|
assert_eq!(range(Some("bytes=10-"), 10), None);
|
||||||
|
assert_eq!(range(Some("bytes=0-1,3-4"), 10), None);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,6 +91,7 @@ mod drive;
|
|||||||
use drive::{DriveApi, RevisionRead};
|
use drive::{DriveApi, RevisionRead};
|
||||||
mod events;
|
mod events;
|
||||||
mod filesystem;
|
mod filesystem;
|
||||||
|
mod gallery;
|
||||||
mod keeper;
|
mod keeper;
|
||||||
mod link;
|
mod link;
|
||||||
pub use filesystem::ProtonFs;
|
pub use filesystem::ProtonFs;
|
||||||
@@ -499,6 +500,7 @@ struct Core {
|
|||||||
/// The concrete client, for what [`DriveApi`] does not cover: sharing,
|
/// The concrete client, for what [`DriveApi`] does not cover: sharing,
|
||||||
/// Photos, devices, invitations and public links.
|
/// Photos, devices, invitations and public links.
|
||||||
client: ProtonDriveClient,
|
client: ProtonDriveClient,
|
||||||
|
gallery: Option<Arc<gallery::Gallery>>,
|
||||||
rt: tokio::runtime::Handle,
|
rt: tokio::runtime::Handle,
|
||||||
/// The daemon's My Files root. Forked on-demand sessions retain this value
|
/// The daemon's My Files root. Forked on-demand sessions retain this value
|
||||||
/// so ownership checks never mistake their own mount root for account scope.
|
/// so ownership checks never mistake their own mount root for account scope.
|
||||||
@@ -4012,6 +4014,15 @@ impl Core {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn has_pending_moves_out_of(&self, uid: &NodeUid) -> Result<bool, Errno> {
|
||||||
|
self.db
|
||||||
|
.has_pending_moves_out_of(&uid.to_string())
|
||||||
|
.map_err(|error| {
|
||||||
|
error!(%uid, %error, "checking for moves out of a trash target failed");
|
||||||
|
Errno::EIO
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Queue trashing a node the server knows about, and drop it from the tree
|
/// Queue trashing a node the server knows about, and drop it from the tree
|
||||||
/// now.
|
/// now.
|
||||||
///
|
///
|
||||||
@@ -5390,6 +5401,11 @@ impl Core {
|
|||||||
&parent_uid,
|
&parent_uid,
|
||||||
)
|
)
|
||||||
.map_err(|error| self.errno_error(error, "trash access"))?;
|
.map_err(|error| self.errno_error(error, "trash access"))?;
|
||||||
|
if self.db.has_pending_moves_out_of(&uid.to_string())? {
|
||||||
|
return Err(CoreError::conflict(
|
||||||
|
"wait for pending moves out of this folder to sync before trashing it",
|
||||||
|
));
|
||||||
|
}
|
||||||
self.rt
|
self.rt
|
||||||
.block_on(self.drive.trash_nodes(std::slice::from_ref(&uid)))
|
.block_on(self.drive.trash_nodes(std::slice::from_ref(&uid)))
|
||||||
.and_then(batch::into_unit)
|
.and_then(batch::into_unit)
|
||||||
@@ -5454,11 +5470,13 @@ impl Core {
|
|||||||
} else {
|
} else {
|
||||||
uid
|
uid
|
||||||
};
|
};
|
||||||
// Local-first or offline, or the network goes away under the call:
|
// Local-first or offline: queue the trash and the rename that follows.
|
||||||
// queue the trash. The rename that follows queues as well, behind it.
|
|
||||||
if !self.sends_inline() {
|
if !self.sends_inline() {
|
||||||
return self.queue_trash(uid, name, open);
|
return self.queue_trash(uid, name, open);
|
||||||
}
|
}
|
||||||
|
if self.has_pending_moves_out_of(uid)? {
|
||||||
|
return Err(Errno::EBUSY);
|
||||||
|
}
|
||||||
self.require_uid_writable(uid)?;
|
self.require_uid_writable(uid)?;
|
||||||
if let Err(e) = self
|
if let Err(e) = self
|
||||||
.block_on_bounded(self.drive.trash_nodes(std::slice::from_ref(uid)))
|
.block_on_bounded(self.drive.trash_nodes(std::slice::from_ref(uid)))
|
||||||
|
|||||||
@@ -232,6 +232,9 @@ impl Core {
|
|||||||
/// Unless the keyring holds a newer session than the refused one: then
|
/// Unless the keyring holds a newer session than the refused one: then
|
||||||
/// the mount ends, for the daemon to mount again on that one.
|
/// the mount ends, for the daemon to mount again on that one.
|
||||||
pub(crate) fn mark_session_expired(&self, what: &str, error: &dyn std::fmt::Display) {
|
pub(crate) fn mark_session_expired(&self, what: &str, error: &dyn std::fmt::Display) {
|
||||||
|
if let Some(gallery) = &self.gallery {
|
||||||
|
gallery.cancel();
|
||||||
|
}
|
||||||
if self.link.resume_stored.load(Ordering::Relaxed) {
|
if self.link.resume_stored.load(Ordering::Relaxed) {
|
||||||
return self.mark_offline(what, error);
|
return self.mark_offline(what, error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ enum Start {
|
|||||||
pub struct MountOptions {
|
pub struct MountOptions {
|
||||||
/// Proton account the session belongs to, for display and per-user paths.
|
/// Proton account the session belongs to, for display and per-user paths.
|
||||||
pub username: String,
|
pub username: String,
|
||||||
|
pub gallery_session: Option<proton_drive_rs::proton_sdk::session::ProtonApiSession>,
|
||||||
/// What the background conflict sweep may do. See `docs/BUGS.md` B71.
|
/// What the background conflict sweep may do. See `docs/BUGS.md` B71.
|
||||||
pub sweep_mode: SweepMode,
|
pub sweep_mode: SweepMode,
|
||||||
/// Upload and download caps in bytes per second (`0` = no cap).
|
/// Upload and download caps in bytes per second (`0` = no cap).
|
||||||
@@ -456,6 +457,7 @@ pub(crate) fn mount_with(
|
|||||||
) -> std::io::Result<MountOutcome> {
|
) -> std::io::Result<MountOutcome> {
|
||||||
let MountOptions {
|
let MountOptions {
|
||||||
username,
|
username,
|
||||||
|
gallery_session,
|
||||||
sweep_mode,
|
sweep_mode,
|
||||||
upload_limit,
|
upload_limit,
|
||||||
download_limit,
|
download_limit,
|
||||||
@@ -480,9 +482,13 @@ pub(crate) fn mount_with(
|
|||||||
let (sync_tx, sync_rx) = std::sync::mpsc::channel::<sync::SyncMsg>();
|
let (sync_tx, sync_rx) = std::sync::mpsc::channel::<sync::SyncMsg>();
|
||||||
|
|
||||||
let paused_until = pause::load_paused_until(&db);
|
let paused_until = pause::load_paused_until(&db);
|
||||||
|
let gallery_dir = control_socket.with_file_name("gallery-catalog");
|
||||||
|
let gallery =
|
||||||
|
gallery_session.map(|session| Arc::new(super::gallery::Gallery::new(gallery_dir, session)));
|
||||||
let core = Core {
|
let core = Core {
|
||||||
drive,
|
drive,
|
||||||
client,
|
client,
|
||||||
|
gallery,
|
||||||
rt: rt.clone(),
|
rt: rt.clone(),
|
||||||
maintenance: Arc::new(Mutex::new(Default::default())),
|
maintenance: Arc::new(Mutex::new(Default::default())),
|
||||||
primary_root_uid: root.uid.clone(),
|
primary_root_uid: root.uid.clone(),
|
||||||
@@ -636,6 +642,9 @@ pub(crate) fn mount_with(
|
|||||||
// Keep the launcher prompt's "This computer" index fresh. Its own thread:
|
// Keep the launcher prompt's "This computer" index fresh. Its own thread:
|
||||||
// the walk is I/O-heavy and must never sit in front of a FUSE callback.
|
// the walk is I/O-heavy and must never sit in front of a FUSE callback.
|
||||||
if matches!(host, Host::Daemon) {
|
if matches!(host, Host::Daemon) {
|
||||||
|
if let Some(gallery) = &core.gallery {
|
||||||
|
rt.spawn(gallery.clone().poll(core.clone()));
|
||||||
|
}
|
||||||
let db = core.db.clone();
|
let db = core.db.clone();
|
||||||
let indexing = core.indexing.clone();
|
let indexing = core.indexing.clone();
|
||||||
let transfers = core.transfers.clone();
|
let transfers = core.transfers.clone();
|
||||||
@@ -954,6 +963,9 @@ fn keep_or_abandon(
|
|||||||
/// Signal every worker to stop, then join them up to [`WORKER_JOIN_DEADLINE`].
|
/// Signal every worker to stop, then join them up to [`WORKER_JOIN_DEADLINE`].
|
||||||
fn halt_workers(core: &Core, control_socket: &Path, workers: Vec<std::thread::JoinHandle<()>>) {
|
fn halt_workers(core: &Core, control_socket: &Path, workers: Vec<std::thread::JoinHandle<()>>) {
|
||||||
core.shutdown.stop();
|
core.shutdown.stop();
|
||||||
|
if let Some(gallery) = &core.gallery {
|
||||||
|
gallery.cancel();
|
||||||
|
}
|
||||||
core.wake_drain();
|
core.wake_drain();
|
||||||
let _ = core.sync_tx.send(sync::SyncMsg::Stop);
|
let _ = core.sync_tx.send(sync::SyncMsg::Stop);
|
||||||
// Connect while the socket still exists — that is the whole point of the
|
// Connect while the socket still exists — that is the whole point of the
|
||||||
|
|||||||
@@ -1175,6 +1175,7 @@ impl Core {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(crate) fn photos_timeline(
|
pub(crate) fn photos_timeline(
|
||||||
&self,
|
&self,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
@@ -1183,6 +1184,7 @@ impl Core {
|
|||||||
range: Option<(i64, i64)>,
|
range: Option<(i64, i64)>,
|
||||||
favorites: bool,
|
favorites: bool,
|
||||||
not_in_album: bool,
|
not_in_album: bool,
|
||||||
|
excluded: &str,
|
||||||
) -> CoreResult<Option<Vec<PhotoItem>>> {
|
) -> CoreResult<Option<Vec<PhotoItem>>> {
|
||||||
let count = self.db.photos_count().map_err(CoreError::from)?;
|
let count = self.db.photos_count().map_err(CoreError::from)?;
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
@@ -1208,7 +1210,15 @@ impl Core {
|
|||||||
|
|
||||||
let page = self
|
let page = self
|
||||||
.db
|
.db
|
||||||
.photos_page(offset, limit, kind, range, favorites, not_in_album)
|
.photos_page_visible(
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
kind,
|
||||||
|
range,
|
||||||
|
favorites,
|
||||||
|
not_in_album,
|
||||||
|
excluded,
|
||||||
|
)
|
||||||
.map_err(CoreError::from)?;
|
.map_err(CoreError::from)?;
|
||||||
Ok(Some(page.into_iter().map(|p| self.photo_item(p)).collect()))
|
Ok(Some(page.into_iter().map(|p| self.photo_item(p)).collect()))
|
||||||
}
|
}
|
||||||
@@ -1365,8 +1375,11 @@ impl Core {
|
|||||||
/// The towns the photos were taken in, as wire items. A town the bundled
|
/// The towns the photos were taken in, as wire items. A town the bundled
|
||||||
/// table no longer knows (the stored id came from an older table) is left
|
/// table no longer knows (the stored id came from an older table) is left
|
||||||
/// out rather than shown without a name.
|
/// out rather than shown without a name.
|
||||||
pub(crate) fn photo_places(&self) -> CoreResult<Vec<PlaceInfo>> {
|
pub(crate) fn photo_places(&self, excluded: &str) -> CoreResult<Vec<PlaceInfo>> {
|
||||||
let places = self.db.photo_places().map_err(CoreError::from)?;
|
let places = self
|
||||||
|
.db
|
||||||
|
.photo_places_visible(excluded)
|
||||||
|
.map_err(CoreError::from)?;
|
||||||
Ok(places
|
Ok(places
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|place| {
|
.filter_map(|place| {
|
||||||
@@ -1390,10 +1403,11 @@ impl Core {
|
|||||||
id: u32,
|
id: u32,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
excluded: &str,
|
||||||
) -> CoreResult<Vec<PhotoItem>> {
|
) -> CoreResult<Vec<PhotoItem>> {
|
||||||
let photos = self
|
let photos = self
|
||||||
.db
|
.db
|
||||||
.photos_at_place(id, offset, limit)
|
.photos_at_place_visible(id, offset, limit, excluded)
|
||||||
.map_err(CoreError::from)?;
|
.map_err(CoreError::from)?;
|
||||||
Ok(photos.into_iter().map(|p| self.photo_item(p)).collect())
|
Ok(photos.into_iter().map(|p| self.photo_item(p)).collect())
|
||||||
}
|
}
|
||||||
@@ -1417,13 +1431,17 @@ impl Core {
|
|||||||
/// Photos taken on today's date in earlier years, as wire items. Served
|
/// Photos taken on today's date in earlier years, as wire items. Served
|
||||||
/// from the stored timeline only: the strip is a nicety, not worth a wait
|
/// from the stored timeline only: the strip is a nicety, not worth a wait
|
||||||
/// on the network, and the timeline's own load keeps that store fresh.
|
/// on the network, and the timeline's own load keeps that store fresh.
|
||||||
pub(crate) fn photos_on_this_day(&self, limit: usize) -> CoreResult<Vec<PhotoItem>> {
|
pub(crate) fn photos_on_this_day(
|
||||||
|
&self,
|
||||||
|
limit: usize,
|
||||||
|
excluded: &str,
|
||||||
|
) -> CoreResult<Vec<PhotoItem>> {
|
||||||
let now = std::time::SystemTime::now()
|
let now = std::time::SystemTime::now()
|
||||||
.duration_since(std::time::UNIX_EPOCH)
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
.map_or(0, |d| d.as_secs() as i64);
|
.map_or(0, |d| d.as_secs() as i64);
|
||||||
let photos = self
|
let photos = self
|
||||||
.db
|
.db
|
||||||
.photos_on_this_day(now, limit)
|
.photos_on_this_day_visible(now, limit, excluded)
|
||||||
.map_err(CoreError::from)?;
|
.map_err(CoreError::from)?;
|
||||||
Ok(photos.into_iter().map(|p| self.photo_item(p)).collect())
|
Ok(photos.into_iter().map(|p| self.photo_item(p)).collect())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ impl Daemon {
|
|||||||
db,
|
db,
|
||||||
MountOptions {
|
MountOptions {
|
||||||
username: "sim".into(),
|
username: "sim".into(),
|
||||||
|
gallery_session: None,
|
||||||
sweep_mode: AppConfig::default().resolved_conflict_sweep(),
|
sweep_mode: AppConfig::default().resolved_conflict_sweep(),
|
||||||
upload_limit: 0,
|
upload_limit: 0,
|
||||||
download_limit: 0,
|
download_limit: 0,
|
||||||
@@ -1917,6 +1918,68 @@ mod tests {
|
|||||||
let _ = std::fs::remove_dir_all(&dir);
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore = "mounts FUSE: run with `cargo test -p pdfs-fuse sim:: -- --ignored`"]
|
||||||
|
fn a_move_blocked_by_trash_can_be_retried_after_restore() {
|
||||||
|
use pdfs_core::control::SyncIssue;
|
||||||
|
|
||||||
|
let drive = FakeDrive::new();
|
||||||
|
let dir = scratch("move-out-of-trash");
|
||||||
|
let daemon = Daemon::start(&dir, drive.client(1, Faults::none())).unwrap();
|
||||||
|
let mount = &daemon.mountpoint;
|
||||||
|
std::fs::create_dir_all(mount.join("source/nested")).unwrap();
|
||||||
|
std::fs::create_dir(mount.join("destination")).unwrap();
|
||||||
|
std::fs::write(mount.join("source/nested/wallpaper.jpg"), b"image").unwrap();
|
||||||
|
assert!(wait_until(Duration::from_secs(30), || daemon.drained()
|
||||||
|
&& drive.lookup("source/nested/wallpaper.jpg").is_some()));
|
||||||
|
let source = drive.lookup("source").unwrap();
|
||||||
|
|
||||||
|
let pause = |paused| Request::SetSyncPaused {
|
||||||
|
paused,
|
||||||
|
until: None,
|
||||||
|
};
|
||||||
|
daemon.request(&pause(true)).unwrap();
|
||||||
|
std::fs::rename(
|
||||||
|
mount.join("source/nested/wallpaper.jpg"),
|
||||||
|
mount.join("destination/wallpaper.jpg"),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
drive.device().trash("source");
|
||||||
|
daemon.request(&pause(false)).unwrap();
|
||||||
|
assert!(wait_until(Duration::from_secs(30), || daemon
|
||||||
|
.pending()
|
||||||
|
.is_ok_and(|ops| ops.iter().any(|op| op.issue
|
||||||
|
== Some(SyncIssue::Trashed)
|
||||||
|
&& op
|
||||||
|
.last_error
|
||||||
|
.as_deref()
|
||||||
|
.is_some_and(|message| message.contains("‘source’"))))));
|
||||||
|
|
||||||
|
daemon
|
||||||
|
.request(&Request::RetryPendingOp { id: None })
|
||||||
|
.unwrap();
|
||||||
|
assert!(wait_until(Duration::from_secs(30), || daemon
|
||||||
|
.pending()
|
||||||
|
.is_ok_and(|ops| ops.iter().any(|op| op.attempts >= 2))));
|
||||||
|
daemon
|
||||||
|
.request(&Request::Restore {
|
||||||
|
uids: vec![source.to_string()],
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
daemon
|
||||||
|
.request(&Request::RetryPendingOp { id: None })
|
||||||
|
.unwrap();
|
||||||
|
assert!(wait_until(Duration::from_secs(30), || daemon.drained()
|
||||||
|
&& drive.lookup("destination/wallpaper.jpg").is_some()));
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read(mount.join("destination/wallpaper.jpg")).unwrap(),
|
||||||
|
b"image"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(matches!(daemon.stop(), Ok(MountOutcome::Shutdown)));
|
||||||
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "mounts FUSE: run with `cargo test -p pdfs-fuse sim:: -- --ignored`"]
|
#[ignore = "mounts FUSE: run with `cargo test -p pdfs-fuse sim:: -- --ignored`"]
|
||||||
fn a_write_over_a_create_whose_read_back_failed_is_not_a_conflict() {
|
fn a_write_over_a_create_whose_read_back_failed_is_not_a_conflict() {
|
||||||
|
|||||||
@@ -160,6 +160,17 @@ impl Server {
|
|||||||
.is_some_and(|remote| remote.file.is_none() && !remote.trashed)
|
.is_some_and(|remote| remote.file.is_none() && !remote.trashed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn in_trash(&self, uid: &NodeUid) -> bool {
|
||||||
|
let mut node = self.current(uid);
|
||||||
|
while let Some(remote) = node {
|
||||||
|
if remote.trashed {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
node = remote.parent.as_ref().and_then(|uid| self.current(uid));
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn is_below(&self, uid: &NodeUid, ancestor: &NodeUid) -> bool {
|
fn is_below(&self, uid: &NodeUid, ancestor: &NodeUid) -> bool {
|
||||||
let mut cursor = Some(uid.clone());
|
let mut cursor = Some(uid.clone());
|
||||||
while let Some(at) = cursor {
|
while let Some(at) = cursor {
|
||||||
@@ -1037,6 +1048,12 @@ impl FakeClient {
|
|||||||
}
|
}
|
||||||
let parent = new_parent.cloned().or(remote.parent.clone());
|
let parent = new_parent.cloned().or(remote.parent.clone());
|
||||||
let name = new_name.unwrap_or(&remote.name).to_owned();
|
let name = new_name.unwrap_or(&remote.name).to_owned();
|
||||||
|
if server.in_trash(uid) || parent.as_ref().is_some_and(|uid| server.in_trash(uid)) {
|
||||||
|
return Err(api(
|
||||||
|
ResponseCode::NotEnoughPermissions,
|
||||||
|
"an item involved in the move is in Trash",
|
||||||
|
));
|
||||||
|
}
|
||||||
if let Some(parent) = &parent {
|
if let Some(parent) = &parent {
|
||||||
if !server.is_folder(parent) {
|
if !server.is_folder(parent) {
|
||||||
return Err(api(
|
return Err(api(
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ struct Run {
|
|||||||
/// Run `profile` on `seed`. It answers a report of what went wrong, if
|
/// Run `profile` on `seed`. It answers a report of what went wrong, if
|
||||||
/// anything did.
|
/// anything did.
|
||||||
pub(crate) fn run(seed: u64, profile: &'static Profile) -> Result<(), String> {
|
pub(crate) fn run(seed: u64, profile: &'static Profile) -> Result<(), String> {
|
||||||
|
// The simulation suite runs serially. Discard logs left by earlier tests.
|
||||||
|
take_logged();
|
||||||
let dir = scratch(&format!("{}-{seed}", profile.name));
|
let dir = scratch(&format!("{}-{seed}", profile.name));
|
||||||
let mut rng = Rng::new(seed);
|
let mut rng = Rng::new(seed);
|
||||||
let drive = FakeDrive::new();
|
let drive = FakeDrive::new();
|
||||||
@@ -137,6 +139,7 @@ pub(crate) fn run(seed: u64, profile: &'static Profile) -> Result<(), String> {
|
|||||||
let _ = daemon.stop();
|
let _ = daemon.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
run.logged.extend(take_logged());
|
||||||
match outcome {
|
match outcome {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
let _ = std::fs::remove_dir_all(&dir);
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
@@ -432,6 +435,7 @@ impl Run {
|
|||||||
|
|
||||||
fn report(&self, failure: &str, dir: &Path) -> String {
|
fn report(&self, failure: &str, dir: &Path) -> String {
|
||||||
let _ = std::fs::write(dir.join("steps.log"), self.log.join("\n") + "\n");
|
let _ = std::fs::write(dir.join("steps.log"), self.log.join("\n") + "\n");
|
||||||
|
let _ = std::fs::write(dir.join("daemon.log"), self.logged.join("\n") + "\n");
|
||||||
let tail = &self.log[self.log.len().saturating_sub(LOG_TAIL)..];
|
let tail = &self.log[self.log.len().saturating_sub(LOG_TAIL)..];
|
||||||
format!(
|
format!(
|
||||||
"{} seed {} failed: {failure}\nreplay with PDFS_SIM_SEED={}; state kept in {}\nlast steps:\n{}",
|
"{} seed {} failed: {failure}\nreplay with PDFS_SIM_SEED={}; state kept in {}\nlast steps:\n{}",
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ name = "pdfs-prompt"
|
|||||||
path = "src/prompt.rs"
|
path = "src/prompt.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
pg-core.workspace = true
|
||||||
|
base64.workspace = true
|
||||||
pdfs-core.workspace = true
|
pdfs-core.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ scale.browser-status-meter trough { min-width: 140px; min-height: 6px; }
|
|||||||
.album-cover { border-radius: 16px; background: alpha(currentColor, 0.06); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32); transition: box-shadow 180ms ease; }
|
.album-cover { border-radius: 16px; background: alpha(currentColor, 0.06); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32); transition: box-shadow 180ms ease; }
|
||||||
.album-card:hover .album-cover { box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5); }
|
.album-card:hover .album-cover { box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5); }
|
||||||
.album-card:hover .photo-thumb { transform: scale(1.05); }
|
.album-card:hover .photo-thumb { transform: scale(1.05); }
|
||||||
|
listview.drive-gallery-rows > row { padding: 0; }
|
||||||
.view-switch button, .view-switch toggle { padding-left: 12px; padding-right: 12px; }
|
.view-switch button, .view-switch toggle { padding-left: 12px; padding-right: 12px; }
|
||||||
|
|
||||||
/* Shared with Me: what a share lets me do, as a tinted pill beside the name. */
|
/* Shared with Me: what a share lets me do, as a tinted pill beside the name. */
|
||||||
|
|||||||
@@ -133,6 +133,32 @@ fn follow_changes(ui: &Rc<Ui>, state: &FeedState, topics: &[Topic]) {
|
|||||||
refresh_file_thumbnails(ui);
|
refresh_file_thumbnails(ui);
|
||||||
}
|
}
|
||||||
let page = ui.stack.visible_child_name();
|
let page = ui.stack.visible_child_name();
|
||||||
|
if changed(Topic::GalleryVisibilitySynced)
|
||||||
|
&& let Some(browser) = ui.drive_galleries.borrow().upgrade()
|
||||||
|
{
|
||||||
|
browser.refresh_visibility();
|
||||||
|
}
|
||||||
|
if changed(Topic::GalleryVisibility) || changed(Topic::GalleryVisibilitySynced) {
|
||||||
|
for window in gtk4::Window::list_toplevels() {
|
||||||
|
if let Ok(window) = window.downcast::<gtk4::Window>()
|
||||||
|
&& window.has_css_class("photo-viewer-window")
|
||||||
|
{
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.gallery.photo_tex.borrow_mut().clear();
|
||||||
|
ui.gallery.photo_tex_order.borrow_mut().clear();
|
||||||
|
ui.gallery.model.remove_all();
|
||||||
|
ui.gallery.groups.remove_all();
|
||||||
|
ui.gallery.timeline_stale.set(true);
|
||||||
|
if page.as_deref() == Some("gallery") {
|
||||||
|
match ui.gallery.content.visible_child_name().as_deref() {
|
||||||
|
Some("albums") => load_albums(ui),
|
||||||
|
Some("places") => load_places(ui),
|
||||||
|
_ => load_gallery(ui, false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// A timeline out of sight is read again when the user comes back to it;
|
// A timeline out of sight is read again when the user comes back to it;
|
||||||
// one on screen is left alone (below).
|
// one on screen is left alone (below).
|
||||||
if changed(Topic::Photos) && (page.as_deref() != Some("gallery") || !photo_grid_shown(ui)) {
|
if changed(Topic::Photos) && (page.as_deref() != Some("gallery") || !photo_grid_shown(ui)) {
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ struct Ui {
|
|||||||
pub(crate) details: DetailsState,
|
pub(crate) details: DetailsState,
|
||||||
pub(crate) trash: TrashState,
|
pub(crate) trash: TrashState,
|
||||||
pub(crate) gallery: GalleryState,
|
pub(crate) gallery: GalleryState,
|
||||||
|
drive_galleries: RefCell<std::rc::Weak<pages::drive_galleries::Browser>>,
|
||||||
pub(crate) shared: SharedState,
|
pub(crate) shared: SharedState,
|
||||||
pub(crate) shared_by_me: SharedByMeState,
|
pub(crate) shared_by_me: SharedByMeState,
|
||||||
pub(crate) devices: DevicesState,
|
pub(crate) devices: DevicesState,
|
||||||
@@ -459,6 +460,7 @@ fn build_window(app: &adw::Application) {
|
|||||||
nav: split.clone(),
|
nav: split.clone(),
|
||||||
narrow: Cell::new(false),
|
narrow: Cell::new(false),
|
||||||
file_thumbs: FileThumbnailState::new(),
|
file_thumbs: FileThumbnailState::new(),
|
||||||
|
drive_galleries: RefCell::default(),
|
||||||
login: login_widgets,
|
login: login_widgets,
|
||||||
status: StatusState {
|
status: StatusState {
|
||||||
status_inflight: Cell::new(false),
|
status_inflight: Cell::new(false),
|
||||||
@@ -760,6 +762,10 @@ fn build_window(app: &adw::Application) {
|
|||||||
&gallery_widgets.scroll,
|
&gallery_widgets.scroll,
|
||||||
&gallery_widgets.square_action,
|
&gallery_widgets.square_action,
|
||||||
);
|
);
|
||||||
|
gallery_widgets.drive_galleries.connect_clicked({
|
||||||
|
let ui = ui.clone();
|
||||||
|
move |_| pages::drive_galleries::open(&ui)
|
||||||
|
});
|
||||||
wire_gallery_empty(
|
wire_gallery_empty(
|
||||||
&ui,
|
&ui,
|
||||||
&gallery_widgets.empty_upload,
|
&gallery_widgets.empty_upload,
|
||||||
|
|||||||
@@ -0,0 +1,822 @@
|
|||||||
|
use crate::*;
|
||||||
|
use base64::{Engine, engine::general_purpose::STANDARD};
|
||||||
|
use pdfs_core::control::{GalleryAction, GalleryAlbum, GalleryFolder, GalleryPlace};
|
||||||
|
|
||||||
|
const PAGE: usize = 150;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
enum Row {
|
||||||
|
Albums(Vec<GalleryAlbum>, i32),
|
||||||
|
Heading(String),
|
||||||
|
Media(Vec<(PhotoItem, (i32, i32))>),
|
||||||
|
Folder(GalleryFolder),
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Place {
|
||||||
|
album: GalleryAlbum,
|
||||||
|
parent_offset: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Browser {
|
||||||
|
ui: Rc<Ui>,
|
||||||
|
window: glib::WeakRef<gtk4::Window>,
|
||||||
|
rows: gio::ListStore,
|
||||||
|
scroll: gtk4::ScrolledWindow,
|
||||||
|
title: adw::WindowTitle,
|
||||||
|
status: gtk4::Label,
|
||||||
|
choose: gtk4::Button,
|
||||||
|
trail: RefCell<Vec<Place>>,
|
||||||
|
chooser: RefCell<Option<Vec<GalleryFolder>>>,
|
||||||
|
cover: RefCell<Option<GalleryPlace>>,
|
||||||
|
albums: RefCell<Vec<GalleryAlbum>>,
|
||||||
|
items: RefCell<Vec<PhotoItem>>,
|
||||||
|
width: Cell<i32>,
|
||||||
|
generation: Cell<u64>,
|
||||||
|
total: Cell<usize>,
|
||||||
|
loading: Cell<bool>,
|
||||||
|
unlocked: Cell<bool>,
|
||||||
|
thumbnail_slots: tokio::sync::Semaphore,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Browser {
|
||||||
|
pub(crate) fn close(&self) {
|
||||||
|
if let Some(window) = self.window.upgrade() {
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn refresh_visibility(self: &Rc<Self>) {
|
||||||
|
if self.chooser.borrow().is_none() {
|
||||||
|
self.trail.borrow_mut().clear();
|
||||||
|
self.cover.borrow_mut().take();
|
||||||
|
self.load(0, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current(&self) -> Option<GalleryAlbum> {
|
||||||
|
self.trail.borrow().last().map(|place| place.album.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn next_request(&self) -> u64 {
|
||||||
|
let next = self.generation.get().wrapping_add(1);
|
||||||
|
self.generation.set(next);
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load(self: &Rc<Self>, offset: usize, restore: f64) {
|
||||||
|
self.choose.set_visible(false);
|
||||||
|
self.loading.set(true);
|
||||||
|
let generation = if offset == 0 {
|
||||||
|
self.total.set(0);
|
||||||
|
self.albums.borrow_mut().clear();
|
||||||
|
self.items.borrow_mut().clear();
|
||||||
|
self.rows.remove_all();
|
||||||
|
self.next_request()
|
||||||
|
} else {
|
||||||
|
self.generation.get()
|
||||||
|
};
|
||||||
|
let album = self.current();
|
||||||
|
self.title.set_title(
|
||||||
|
album
|
||||||
|
.as_ref()
|
||||||
|
.map_or_else(|| gettext("Drive Galleries"), |a| a.folder.name.clone())
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
self.status.set_label(&gettext("Loading…"));
|
||||||
|
let rx = spawn_request(
|
||||||
|
self.ui.dirs.control_socket(),
|
||||||
|
Request::DriveGallery {
|
||||||
|
action: GalleryAction::List {
|
||||||
|
album: album.map(|a| a.place),
|
||||||
|
offset,
|
||||||
|
limit: PAGE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let browser = self.clone();
|
||||||
|
glib::spawn_future_local(async move {
|
||||||
|
let result = rx.recv().await;
|
||||||
|
if browser.generation.get() != generation {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
browser.loading.set(false);
|
||||||
|
match result {
|
||||||
|
Ok(Ok(Response::GalleryPage {
|
||||||
|
albums,
|
||||||
|
items,
|
||||||
|
total,
|
||||||
|
})) => {
|
||||||
|
if offset == 0 {
|
||||||
|
*browser.albums.borrow_mut() = albums;
|
||||||
|
}
|
||||||
|
browser.items.borrow_mut().extend(items);
|
||||||
|
browser.total.set(total);
|
||||||
|
let empty = total == 0 && browser.albums.borrow().is_empty();
|
||||||
|
let message = if browser.cover.borrow().is_some() {
|
||||||
|
gettext("Choose a photo or video as the album cover.")
|
||||||
|
} else if empty {
|
||||||
|
gettext("This gallery is empty.")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
browser.status.set_label(&message);
|
||||||
|
browser.rebuild();
|
||||||
|
if restore > 0.0 {
|
||||||
|
let scroll = browser.scroll.clone();
|
||||||
|
glib::idle_add_local_once(move || scroll.vadjustment().set_value(restore));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(Ok(Response::Error { message, .. })) => browser.status.set_label(&message),
|
||||||
|
_ => browser
|
||||||
|
.status
|
||||||
|
.set_label(&gettext("Couldn't reach Proton Drive.")),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn browse_folders(self: &Rc<Self>) {
|
||||||
|
let Some(trail) = self.chooser.borrow().clone() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let generation = self.next_request();
|
||||||
|
let parent = trail.last().map(|folder| folder.uid.clone());
|
||||||
|
self.choose.set_visible(parent.is_some());
|
||||||
|
self.title.set_title(&gettext("Choose a Drive Folder"));
|
||||||
|
self.rows.remove_all();
|
||||||
|
let rx = spawn_request(
|
||||||
|
self.ui.dirs.control_socket(),
|
||||||
|
Request::DriveGallery {
|
||||||
|
action: GalleryAction::Folders { parent },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let browser = self.clone();
|
||||||
|
glib::spawn_future_local(async move {
|
||||||
|
let result = rx.recv().await;
|
||||||
|
if browser.generation.get() != generation {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
match result {
|
||||||
|
Ok(Ok(Response::GalleryFolders { folders })) => {
|
||||||
|
browser
|
||||||
|
.status
|
||||||
|
.set_label(&gettext("Open a folder, then choose Add This Folder."));
|
||||||
|
for folder in folders {
|
||||||
|
browser
|
||||||
|
.rows
|
||||||
|
.append(&BoxedAnyObject::new(Row::Folder(folder)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(Ok(Response::Error { message, .. })) => browser.status.set_label(&message),
|
||||||
|
_ => browser
|
||||||
|
.status
|
||||||
|
.set_label(&gettext("Couldn't reach Proton Drive.")),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn change(self: &Rc<Self>, action: GalleryAction) {
|
||||||
|
let unlock = matches!(action, GalleryAction::Unlock { .. });
|
||||||
|
let lock = matches!(action, GalleryAction::Lock);
|
||||||
|
if lock {
|
||||||
|
self.trail.borrow_mut().clear();
|
||||||
|
self.cover.borrow_mut().take();
|
||||||
|
self.items.borrow_mut().clear();
|
||||||
|
self.rows.remove_all();
|
||||||
|
}
|
||||||
|
let generation = self.next_request();
|
||||||
|
self.status.set_label(&gettext("Updating gallery…"));
|
||||||
|
let rx = spawn_request(
|
||||||
|
self.ui.dirs.control_socket(),
|
||||||
|
Request::DriveGallery { action },
|
||||||
|
);
|
||||||
|
let browser = self.clone();
|
||||||
|
glib::spawn_future_local(async move {
|
||||||
|
let result = rx.recv().await;
|
||||||
|
if browser.generation.get() != generation {
|
||||||
|
if unlock && matches!(result, Ok(Ok(Response::Ok { .. }))) {
|
||||||
|
browser.lock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
match result {
|
||||||
|
Ok(Ok(Response::Ok { .. })) => {
|
||||||
|
if unlock || lock {
|
||||||
|
browser.unlocked.set(unlock);
|
||||||
|
}
|
||||||
|
browser.chooser.borrow_mut().take();
|
||||||
|
browser.load(0, 0.0);
|
||||||
|
}
|
||||||
|
Ok(Ok(Response::Error { message, .. })) => browser.status.set_label(&message),
|
||||||
|
_ => browser
|
||||||
|
.status
|
||||||
|
.set_label(&gettext("Couldn't reach Proton Drive.")),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lock(&self) {
|
||||||
|
let _ = spawn_request(
|
||||||
|
self.ui.dirs.control_socket(),
|
||||||
|
Request::DriveGallery {
|
||||||
|
action: GalleryAction::Lock,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prompt_unlock(self: &Rc<Self>) {
|
||||||
|
let Some(parent) = self.window.upgrade() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let dialog = adw::AlertDialog::builder()
|
||||||
|
.heading(gettext("Unlock Hidden Albums"))
|
||||||
|
.body(gettext("Enter your Gallery passphrase. On first use, choose one with at least 12 characters."))
|
||||||
|
.build();
|
||||||
|
let password = gtk4::PasswordEntry::builder().show_peek_icon(true).build();
|
||||||
|
dialog.set_extra_child(Some(&password));
|
||||||
|
dialog.add_response("cancel", &gettext("Cancel"));
|
||||||
|
dialog.add_response("unlock", &gettext("Unlock"));
|
||||||
|
dialog.set_response_appearance("unlock", adw::ResponseAppearance::Suggested);
|
||||||
|
dialog.set_default_response(Some("unlock"));
|
||||||
|
let browser = Rc::downgrade(self);
|
||||||
|
dialog.connect_response(None, move |_, response| {
|
||||||
|
let passphrase = password.text().to_string();
|
||||||
|
password.set_text("");
|
||||||
|
if response == "unlock"
|
||||||
|
&& let Some(browser) = browser.upgrade()
|
||||||
|
{
|
||||||
|
browser.change(GalleryAction::Unlock { passphrase });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.present(Some(&parent));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn back(self: &Rc<Self>) {
|
||||||
|
let choosing = self.chooser.borrow().is_some();
|
||||||
|
if choosing {
|
||||||
|
let went_up = self
|
||||||
|
.chooser
|
||||||
|
.borrow_mut()
|
||||||
|
.as_mut()
|
||||||
|
.and_then(Vec::pop)
|
||||||
|
.is_some();
|
||||||
|
if went_up {
|
||||||
|
self.browse_folders();
|
||||||
|
} else {
|
||||||
|
self.chooser.borrow_mut().take();
|
||||||
|
self.load(0, 0.0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let at_target = self
|
||||||
|
.cover
|
||||||
|
.borrow()
|
||||||
|
.as_ref()
|
||||||
|
.zip(self.current())
|
||||||
|
.is_some_and(|(target, current)| target.album == current.place.album);
|
||||||
|
if at_target {
|
||||||
|
self.cover.borrow_mut().take();
|
||||||
|
self.status.set_label("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let previous = self.trail.borrow_mut().pop();
|
||||||
|
if let Some(previous) = previous {
|
||||||
|
self.load(0, previous.parent_offset);
|
||||||
|
} else if let Some(window) = self.window.upgrade() {
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rebuild(&self) {
|
||||||
|
if self.chooser.borrow().is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let width = (self.width.get() - 24).max(240);
|
||||||
|
let columns = ((width + 8) / 216).max(1);
|
||||||
|
let card = (width - 8 * (columns - 1)) / columns;
|
||||||
|
let mut rows = Vec::new();
|
||||||
|
for albums in self.albums.borrow().chunks(columns as usize) {
|
||||||
|
rows.push(BoxedAnyObject::new(Row::Albums(albums.to_vec(), card)));
|
||||||
|
}
|
||||||
|
let items = self.items.borrow();
|
||||||
|
let period = |item: &PhotoItem| {
|
||||||
|
glib::DateTime::from_unix_local(item.capture_time)
|
||||||
|
.ok()
|
||||||
|
.and_then(|date| date.format("%B %Y").ok())
|
||||||
|
.map(|value| value.to_string())
|
||||||
|
.unwrap_or_else(|| gettext("Unknown date"))
|
||||||
|
};
|
||||||
|
for section in items.chunk_by(|a, b| period(a) == period(b)) {
|
||||||
|
rows.push(BoxedAnyObject::new(Row::Heading(period(§ion[0]))));
|
||||||
|
let ratios: Vec<_> = section
|
||||||
|
.iter()
|
||||||
|
.map(|item| item.ratio.unwrap_or(1.0))
|
||||||
|
.collect();
|
||||||
|
let mut items = section.iter();
|
||||||
|
for sizes in super::photos::plan_justified(&ratios, width, 180) {
|
||||||
|
rows.push(BoxedAnyObject::new(Row::Media(
|
||||||
|
items.by_ref().cloned().zip(sizes).collect(),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.rows.splice(0, self.rows.n_items(), &rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn preview(self: &Rc<Self>, item: PhotoItem) {
|
||||||
|
let video = item.kind == PhotoKind::Video;
|
||||||
|
let request = if video {
|
||||||
|
Request::OpenGalleryVideo { uid: item.uid }
|
||||||
|
} else {
|
||||||
|
Request::OpenGalleryImage { uid: item.uid }
|
||||||
|
};
|
||||||
|
let reply = spawn_request(self.ui.dirs.control_socket(), request);
|
||||||
|
let browser = self.clone();
|
||||||
|
let generation = self.generation.get();
|
||||||
|
glib::spawn_future_local(async move {
|
||||||
|
let result = reply.recv().await;
|
||||||
|
let close = |token| {
|
||||||
|
let _ = spawn_request(
|
||||||
|
browser.ui.dirs.control_socket(),
|
||||||
|
Request::CloseGalleryVideo { token },
|
||||||
|
);
|
||||||
|
};
|
||||||
|
let parent = browser
|
||||||
|
.window
|
||||||
|
.upgrade()
|
||||||
|
.filter(|_| generation == browser.generation.get());
|
||||||
|
let Some(parent) = parent else {
|
||||||
|
if let Ok(Ok(Response::GalleryVideo { token, .. })) = result {
|
||||||
|
close(token);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let preview = gtk4::Window::builder()
|
||||||
|
.transient_for(&parent)
|
||||||
|
.destroy_with_parent(true)
|
||||||
|
.title(item.name.unwrap_or_else(|| gettext("Preview")))
|
||||||
|
.default_width(850)
|
||||||
|
.default_height(600)
|
||||||
|
.build();
|
||||||
|
preview.add_css_class("photo-viewer-window");
|
||||||
|
match result {
|
||||||
|
Ok(Ok(Response::GalleryVideo { url, token, .. })) => {
|
||||||
|
let player = gtk4::Video::builder().autoplay(true).build();
|
||||||
|
player.set_file(Some(&gio::File::for_uri(&url)));
|
||||||
|
preview.set_child(Some(&player));
|
||||||
|
let socket = browser.ui.dirs.control_socket();
|
||||||
|
preview.connect_close_request(move |_| {
|
||||||
|
player.set_media_stream(gtk4::MediaStream::NONE);
|
||||||
|
let _ = spawn_request(
|
||||||
|
socket.clone(),
|
||||||
|
Request::CloseGalleryVideo {
|
||||||
|
token: token.clone(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
glib::Propagation::Proceed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(Ok(Response::FilePath { path })) => {
|
||||||
|
let picture = gtk4::Picture::for_filename(path);
|
||||||
|
preview.set_child(Some(&picture));
|
||||||
|
}
|
||||||
|
Ok(Ok(Response::Error { message, .. })) => {
|
||||||
|
browser.status.set_label(&message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
browser
|
||||||
|
.status
|
||||||
|
.set_label(&gettext("Couldn't open the file."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
preview.present();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn open(ui: &Rc<Ui>) {
|
||||||
|
if let Some(browser) = ui.drive_galleries.borrow().upgrade()
|
||||||
|
&& let Some(window) = browser.window.upgrade()
|
||||||
|
{
|
||||||
|
window.present();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let Some(parent) = ui_window(ui) else { return };
|
||||||
|
let window = gtk4::Window::builder()
|
||||||
|
.transient_for(&parent)
|
||||||
|
.default_width(1020)
|
||||||
|
.default_height(760)
|
||||||
|
.build();
|
||||||
|
let title = adw::WindowTitle::new(&gettext("Drive Galleries"), "");
|
||||||
|
let header = adw::HeaderBar::builder().title_widget(&title).build();
|
||||||
|
let back = gtk4::Button::from_icon_name("go-previous-symbolic");
|
||||||
|
back.set_tooltip_text(Some(&gettext("Back")));
|
||||||
|
header.pack_start(&back);
|
||||||
|
let add = gtk4::Button::with_label(&gettext("Add Gallery"));
|
||||||
|
let choose = gtk4::Button::with_label(&gettext("Add This Folder"));
|
||||||
|
choose.set_visible(false);
|
||||||
|
header.pack_end(&add);
|
||||||
|
header.pack_end(&choose);
|
||||||
|
let more = gtk4::Button::from_icon_name("view-more-symbolic");
|
||||||
|
more.set_tooltip_text(Some(&gettext("Gallery Options")));
|
||||||
|
header.pack_end(&more);
|
||||||
|
let rows = gio::ListStore::new::<BoxedAnyObject>();
|
||||||
|
let factory = gtk4::SignalListItemFactory::new();
|
||||||
|
let list = gtk4::ListView::builder()
|
||||||
|
.model(>k4::NoSelection::new(Some(rows.clone())))
|
||||||
|
.factory(&factory)
|
||||||
|
.build();
|
||||||
|
list.add_css_class("drive-gallery-rows");
|
||||||
|
let scroll = gtk4::ScrolledWindow::builder()
|
||||||
|
.vexpand(true)
|
||||||
|
.hscrollbar_policy(gtk4::PolicyType::External)
|
||||||
|
.child(&list)
|
||||||
|
.build();
|
||||||
|
let status = gtk4::Label::new(None);
|
||||||
|
status.set_wrap(true);
|
||||||
|
let content = gtk4::Box::new(gtk4::Orientation::Vertical, 0);
|
||||||
|
content.append(&header);
|
||||||
|
content.append(&status);
|
||||||
|
content.append(&scroll);
|
||||||
|
window.set_child(Some(&content));
|
||||||
|
let browser = Rc::new(Browser {
|
||||||
|
ui: ui.clone(),
|
||||||
|
window: window.downgrade(),
|
||||||
|
rows,
|
||||||
|
scroll: scroll.clone(),
|
||||||
|
title,
|
||||||
|
status,
|
||||||
|
choose: choose.clone(),
|
||||||
|
trail: RefCell::new(Vec::new()),
|
||||||
|
chooser: RefCell::new(None),
|
||||||
|
cover: RefCell::new(None),
|
||||||
|
albums: RefCell::new(Vec::new()),
|
||||||
|
items: RefCell::new(Vec::new()),
|
||||||
|
width: Cell::new(0),
|
||||||
|
generation: Cell::new(0),
|
||||||
|
total: Cell::new(0),
|
||||||
|
loading: Cell::new(false),
|
||||||
|
unlocked: Cell::new(false),
|
||||||
|
thumbnail_slots: tokio::sync::Semaphore::new(8),
|
||||||
|
});
|
||||||
|
*ui.drive_galleries.borrow_mut() = Rc::downgrade(&browser);
|
||||||
|
window.connect_close_request({
|
||||||
|
let browser = browser.clone();
|
||||||
|
move |_| {
|
||||||
|
*browser.ui.drive_galleries.borrow_mut() = std::rc::Weak::new();
|
||||||
|
browser.next_request();
|
||||||
|
if browser.unlocked.get() {
|
||||||
|
browser.lock();
|
||||||
|
}
|
||||||
|
glib::Propagation::Proceed
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
factory.connect_bind(move |_, item| {
|
||||||
|
let Some(browser) = weak.upgrade() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(list_item) = item.downcast_ref::<gtk4::ListItem>() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(data) = list_item.item().and_downcast::<BoxedAnyObject>() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let row = data.borrow::<Row>();
|
||||||
|
let line = gtk4::Box::new(gtk4::Orientation::Horizontal, 8);
|
||||||
|
line.set_margin_start(12);
|
||||||
|
line.set_margin_end(12);
|
||||||
|
line.set_margin_bottom(8);
|
||||||
|
match &*row {
|
||||||
|
Row::Heading(label) => {
|
||||||
|
let label = gtk4::Label::new(Some(label));
|
||||||
|
label.add_css_class("heading");
|
||||||
|
line.append(&label);
|
||||||
|
}
|
||||||
|
Row::Folder(folder) => {
|
||||||
|
let button = gtk4::Button::with_label(&folder.name);
|
||||||
|
button.set_hexpand(true);
|
||||||
|
button.connect_clicked({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
let folder = folder.clone();
|
||||||
|
move |_| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
if let Some(trail) = browser.chooser.borrow_mut().as_mut() {
|
||||||
|
trail.push(folder.clone());
|
||||||
|
}
|
||||||
|
browser.browse_folders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
line.append(&button);
|
||||||
|
}
|
||||||
|
Row::Albums(albums, width) => {
|
||||||
|
for album in albums {
|
||||||
|
let items = ngettext_f("{n} item", "{n} items", album.items, &[]);
|
||||||
|
let mut detail = if album.folders > 0 {
|
||||||
|
let folders = ngettext_f("{n} folder", "{n} folders", album.folders, &[]);
|
||||||
|
format!("{items} · {folders}")
|
||||||
|
} else {
|
||||||
|
items
|
||||||
|
};
|
||||||
|
if album.hidden {
|
||||||
|
detail = format!("{detail} · {}", gettext("Hidden"));
|
||||||
|
}
|
||||||
|
let button = tile(
|
||||||
|
&browser,
|
||||||
|
&album.folder.name,
|
||||||
|
album.cover.as_deref(),
|
||||||
|
*width,
|
||||||
|
130,
|
||||||
|
Some(&detail),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
button.connect_clicked({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
let album = album.clone();
|
||||||
|
move |_| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
browser.trail.borrow_mut().push(Place {
|
||||||
|
album: album.clone(),
|
||||||
|
parent_offset: browser.scroll.vadjustment().value(),
|
||||||
|
});
|
||||||
|
browser.load(0, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
line.append(&button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row::Media(items) => {
|
||||||
|
line.set_spacing(super::photos::TILE_GAP);
|
||||||
|
for (item, (width, height)) in items {
|
||||||
|
let button = tile(
|
||||||
|
&browser,
|
||||||
|
item.name.as_deref().unwrap_or(""),
|
||||||
|
Some(&item.uid),
|
||||||
|
*width,
|
||||||
|
*height,
|
||||||
|
None,
|
||||||
|
item.kind == PhotoKind::Video,
|
||||||
|
);
|
||||||
|
button.connect_clicked({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
let item = item.clone();
|
||||||
|
move |_| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
let cover = browser.cover.borrow_mut().take();
|
||||||
|
if let Some(album) = cover {
|
||||||
|
browser.change(GalleryAction::Cover {
|
||||||
|
album,
|
||||||
|
uid: item.uid.clone(),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
browser.preview(item.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
line.append(&button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list_item.set_child(Some(&line));
|
||||||
|
});
|
||||||
|
factory.connect_unbind(|_, item| {
|
||||||
|
if let Some(item) = item.downcast_ref::<gtk4::ListItem>() {
|
||||||
|
item.set_child(gtk4::Widget::NONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
back.connect_clicked({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
move |_| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
browser.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add.connect_clicked({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
let choose = choose.clone();
|
||||||
|
move |_| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
choose.set_visible(true);
|
||||||
|
*browser.chooser.borrow_mut() = Some(Vec::new());
|
||||||
|
browser.browse_folders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
choose.connect_clicked({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
move |button| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
let uid = browser
|
||||||
|
.chooser
|
||||||
|
.borrow()
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|trail| trail.last())
|
||||||
|
.map(|f| f.uid.clone());
|
||||||
|
if let Some(uid) = uid {
|
||||||
|
button.set_visible(false);
|
||||||
|
browser.change(GalleryAction::Add { uid });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
more.connect_clicked({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
move |button| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
let mut menu = ActionMenu::new();
|
||||||
|
menu.item(&gettext("Refresh"), {
|
||||||
|
let browser = browser.clone();
|
||||||
|
move || browser.change(GalleryAction::Refresh)
|
||||||
|
});
|
||||||
|
if browser.unlocked.get() {
|
||||||
|
menu.item(&gettext("Lock Hidden Albums"), {
|
||||||
|
let browser = browser.clone();
|
||||||
|
move || browser.change(GalleryAction::Lock)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
menu.item(&gettext("Unlock Hidden Albums"), {
|
||||||
|
let browser = browser.clone();
|
||||||
|
move || browser.prompt_unlock()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if let Some(album) = browser.current() {
|
||||||
|
menu.item(&gettext("Choose Cover"), {
|
||||||
|
let browser = browser.clone();
|
||||||
|
let place = album.place.clone();
|
||||||
|
move || {
|
||||||
|
*browser.cover.borrow_mut() = Some(place.clone());
|
||||||
|
browser.status.set_label(&gettext(
|
||||||
|
"Choose a photo or video from this album or a subfolder.",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.item(&gettext("Public Link"), {
|
||||||
|
let browser = browser.clone();
|
||||||
|
let folder = album.folder.clone();
|
||||||
|
move || {
|
||||||
|
open_share_dialog_over(
|
||||||
|
&browser.ui,
|
||||||
|
&DirEntry {
|
||||||
|
uid: folder.uid.clone(),
|
||||||
|
name: folder.name.clone(),
|
||||||
|
is_dir: true,
|
||||||
|
..DirEntry::default()
|
||||||
|
},
|
||||||
|
browser.window.upgrade(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if browser.trail.borrow().len() == 1 {
|
||||||
|
menu.item(&gettext("Remove Gallery"), {
|
||||||
|
let browser = browser.clone();
|
||||||
|
move || {
|
||||||
|
browser.trail.borrow_mut().clear();
|
||||||
|
browser.change(GalleryAction::Remove {
|
||||||
|
gallery: album.place.gallery.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menu.popup_at(
|
||||||
|
button,
|
||||||
|
f64::from(button.width()) / 2.0,
|
||||||
|
f64::from(button.height()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
scroll.vadjustment().connect_value_changed({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
move |adj| {
|
||||||
|
if let Some(browser) = weak.upgrade() {
|
||||||
|
let offset = browser.items.borrow().len();
|
||||||
|
if browser.chooser.borrow().is_none()
|
||||||
|
&& !browser.loading.get()
|
||||||
|
&& offset < browser.total.get()
|
||||||
|
&& adj.value() + adj.page_size() + 800.0 >= adj.upper()
|
||||||
|
{
|
||||||
|
browser.load(offset, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
scroll.add_tick_callback({
|
||||||
|
let weak = Rc::downgrade(&browser);
|
||||||
|
move |scroll, _| {
|
||||||
|
let Some(browser) = weak.upgrade() else {
|
||||||
|
return glib::ControlFlow::Break;
|
||||||
|
};
|
||||||
|
let width = scroll.width();
|
||||||
|
if width > 0 && browser.width.replace(width) != width {
|
||||||
|
browser.rebuild();
|
||||||
|
}
|
||||||
|
glib::ControlFlow::Continue
|
||||||
|
}
|
||||||
|
});
|
||||||
|
window.present();
|
||||||
|
browser.load(0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tile(
|
||||||
|
browser: &Rc<Browser>,
|
||||||
|
title: &str,
|
||||||
|
uid: Option<&str>,
|
||||||
|
width: i32,
|
||||||
|
height: i32,
|
||||||
|
detail: Option<&str>,
|
||||||
|
video: bool,
|
||||||
|
) -> gtk4::Button {
|
||||||
|
let picture = gtk4::Picture::builder()
|
||||||
|
.content_fit(gtk4::ContentFit::Cover)
|
||||||
|
.can_shrink(true)
|
||||||
|
.width_request(if detail.is_some() {
|
||||||
|
(width - 24).max(1)
|
||||||
|
} else {
|
||||||
|
width
|
||||||
|
})
|
||||||
|
.height_request(height)
|
||||||
|
.build();
|
||||||
|
let label = gtk4::Label::new(Some(title));
|
||||||
|
label.set_ellipsize(gtk4::pango::EllipsizeMode::End);
|
||||||
|
label.set_max_width_chars((width / 9).max(1));
|
||||||
|
let box_ = gtk4::Box::new(gtk4::Orientation::Vertical, 4);
|
||||||
|
let cover = gtk4::Overlay::new();
|
||||||
|
cover.set_child(Some(&picture));
|
||||||
|
let icon = gtk4::Image::from_icon_name(if detail.is_some() {
|
||||||
|
"folder-symbolic"
|
||||||
|
} else {
|
||||||
|
"image-x-generic-symbolic"
|
||||||
|
});
|
||||||
|
icon.set_halign(gtk4::Align::Center);
|
||||||
|
icon.set_valign(gtk4::Align::Center);
|
||||||
|
icon.set_pixel_size(32);
|
||||||
|
icon.add_css_class("dim-label");
|
||||||
|
cover.add_overlay(&icon);
|
||||||
|
cover.set_overflow(gtk4::Overflow::Hidden);
|
||||||
|
let button = gtk4::Button::builder().tooltip_text(title).build();
|
||||||
|
if let Some(detail) = detail {
|
||||||
|
box_.append(&cover);
|
||||||
|
box_.append(&label);
|
||||||
|
let caption = gtk4::Label::new(Some(detail));
|
||||||
|
caption.add_css_class("dim-label");
|
||||||
|
caption.add_css_class("caption");
|
||||||
|
caption.set_ellipsize(gtk4::pango::EllipsizeMode::End);
|
||||||
|
box_.append(&caption);
|
||||||
|
button.set_width_request(width);
|
||||||
|
button.set_child(Some(&box_));
|
||||||
|
} else {
|
||||||
|
button.add_css_class("photo-tile");
|
||||||
|
cover.add_css_class("photo-placeholder");
|
||||||
|
label.add_css_class("photo-caption");
|
||||||
|
label.set_valign(gtk4::Align::End);
|
||||||
|
cover.add_overlay(&label);
|
||||||
|
if video {
|
||||||
|
let play = gtk4::Image::from_icon_name("media-playback-start-symbolic");
|
||||||
|
play.add_css_class("photo-video-badge");
|
||||||
|
play.add_css_class("photo-video-badge-small");
|
||||||
|
play.set_halign(gtk4::Align::End);
|
||||||
|
play.set_valign(gtk4::Align::Start);
|
||||||
|
play.set_margin_end(8);
|
||||||
|
play.set_margin_top(8);
|
||||||
|
cover.add_overlay(&play);
|
||||||
|
}
|
||||||
|
button.set_child(Some(&cover));
|
||||||
|
}
|
||||||
|
if let Some(uid) = uid {
|
||||||
|
let browser = browser.clone();
|
||||||
|
let generation = browser.generation.get();
|
||||||
|
let uid = uid.to_owned();
|
||||||
|
let picture = picture.downgrade();
|
||||||
|
let icon = icon.downgrade();
|
||||||
|
glib::spawn_future_local(async move {
|
||||||
|
let Ok(_permit) = browser.thumbnail_slots.acquire().await else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if picture.upgrade().is_none() || generation != browser.generation.get() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let request = spawn_request(
|
||||||
|
browser.ui.dirs.control_socket(),
|
||||||
|
Request::GalleryThumbnail { uid },
|
||||||
|
);
|
||||||
|
let response = request.recv().await;
|
||||||
|
if generation == browser.generation.get()
|
||||||
|
&& let (Some(picture), Ok(Ok(Response::GalleryThumbnail { data: Some(data) }))) =
|
||||||
|
(picture.upgrade(), response)
|
||||||
|
&& let Ok(bytes) = STANDARD.decode(data)
|
||||||
|
&& let Ok(texture) = gtk4::gdk::Texture::from_bytes(&glib::Bytes::from_owned(bytes))
|
||||||
|
{
|
||||||
|
picture.set_paintable(Some(&texture));
|
||||||
|
if let Some(icon) = icon.upgrade() {
|
||||||
|
icon.set_visible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
button
|
||||||
|
}
|
||||||
@@ -788,6 +788,9 @@ pub(crate) fn issue_text(issue: SyncIssue) -> String {
|
|||||||
SyncIssue::Access => gettext(
|
SyncIssue::Access => gettext(
|
||||||
"You can no longer change this on Proton Drive. Ask the owner for edit access, or export the file to keep your version.",
|
"You can no longer change this on Proton Drive. Ask the owner for edit access, or export the file to keep your version.",
|
||||||
),
|
),
|
||||||
|
SyncIssue::Trashed => {
|
||||||
|
gettext("Restore the item or folder from Trash, then retry the move.")
|
||||||
|
}
|
||||||
SyncIssue::Missing => gettext(
|
SyncIssue::Missing => gettext(
|
||||||
"The folder this change belongs in is gone from Proton Drive. Export the file to keep your version.",
|
"The folder this change belongs in is gone from Proton Drive. Export the file to keep your version.",
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -683,6 +683,10 @@ pub(crate) fn sign_out(ui: &Rc<Ui>) {
|
|||||||
),
|
),
|
||||||
&gettext("Sign Out"),
|
&gettext("Sign Out"),
|
||||||
move || {
|
move || {
|
||||||
|
let galleries = ui.drive_galleries.borrow().upgrade();
|
||||||
|
if let Some(galleries) = galleries {
|
||||||
|
galleries.close();
|
||||||
|
}
|
||||||
// systemctl and the keyring both block, so run them on a worker.
|
// systemctl and the keyring both block, so run them on a worker.
|
||||||
let ui = ui.clone();
|
let ui = ui.clone();
|
||||||
glib::spawn_future_local(async move {
|
glib::spawn_future_local(async move {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ pub(crate) mod activity_text;
|
|||||||
pub(crate) mod albums;
|
pub(crate) mod albums;
|
||||||
pub(crate) mod browser;
|
pub(crate) mod browser;
|
||||||
pub(crate) mod devices;
|
pub(crate) mod devices;
|
||||||
|
pub(crate) mod drive_galleries;
|
||||||
pub(crate) mod duplicates;
|
pub(crate) mod duplicates;
|
||||||
pub(crate) mod locations;
|
pub(crate) mod locations;
|
||||||
pub(crate) mod login;
|
pub(crate) mod login;
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ pub(crate) struct Viewer {
|
|||||||
pub(crate) scroller: gtk4::ScrolledWindow,
|
pub(crate) scroller: gtk4::ScrolledWindow,
|
||||||
pub(crate) picture: gtk4::Picture,
|
pub(crate) picture: gtk4::Picture,
|
||||||
pub(crate) video: gtk4::Video,
|
pub(crate) video: gtk4::Video,
|
||||||
|
video_token: RefCell<Option<String>>,
|
||||||
|
load_generation: Cell<u64>,
|
||||||
pub(crate) spinner: Spinner,
|
pub(crate) spinner: Spinner,
|
||||||
pub(crate) status: gtk4::Label,
|
pub(crate) status: gtk4::Label,
|
||||||
pub(crate) title: gtk4::Label,
|
pub(crate) title: gtk4::Label,
|
||||||
@@ -272,12 +274,14 @@ fn viewer_item(ui: &Rc<Ui>, viewer: &Rc<Viewer>, uid: &str) -> Option<PhotoItem>
|
|||||||
/// full-size file, and swap it in — plus its EXIF — when it lands. A video
|
/// full-size file, and swap it in — plus its EXIF — when it lands. A video
|
||||||
/// plays in place once its file is down.
|
/// plays in place once its file is down.
|
||||||
pub(crate) fn load_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>, uid: String) {
|
pub(crate) fn load_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>, uid: String) {
|
||||||
|
let generation = viewer.load_generation.get().wrapping_add(1);
|
||||||
|
viewer.load_generation.set(generation);
|
||||||
viewer.spinner.set_visible(true);
|
viewer.spinner.set_visible(true);
|
||||||
viewer.status.set_visible(false);
|
viewer.status.set_visible(false);
|
||||||
viewer.loading.set(true);
|
viewer.loading.set(true);
|
||||||
*viewer.path.borrow_mut() = None;
|
*viewer.path.borrow_mut() = None;
|
||||||
clear_info(viewer);
|
clear_info(viewer);
|
||||||
stop_video(viewer);
|
stop_video(ui, viewer);
|
||||||
viewer.media.set_visible_child_name("photo");
|
viewer.media.set_visible_child_name("photo");
|
||||||
sync_strip(viewer);
|
sync_strip(viewer);
|
||||||
reset_zoom(viewer);
|
reset_zoom(viewer);
|
||||||
@@ -302,17 +306,22 @@ pub(crate) fn load_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>, uid: String) {
|
|||||||
None => viewer.picture.set_paintable(gtk4::gdk::Paintable::NONE),
|
None => viewer.picture.set_paintable(gtk4::gdk::Paintable::NONE),
|
||||||
}
|
}
|
||||||
|
|
||||||
let rx = spawn_request(
|
let request = if is_video {
|
||||||
ui.dirs.control_socket(),
|
Request::OpenGalleryVideo { uid: uid.clone() }
|
||||||
Request::OpenPhoto { uid: uid.clone() },
|
} else {
|
||||||
);
|
Request::OpenPhoto { uid: uid.clone() }
|
||||||
|
};
|
||||||
|
let rx = spawn_request(ui.dirs.control_socket(), request);
|
||||||
let viewer = viewer.clone();
|
let viewer = viewer.clone();
|
||||||
let ui = ui.clone();
|
let ui = ui.clone();
|
||||||
glib::spawn_future_local(async move {
|
glib::spawn_future_local(async move {
|
||||||
let result = rx.recv().await;
|
let result = rx.recv().await;
|
||||||
// The user may have moved on while this was in flight; that photo's own
|
// The user may have moved on while this was in flight; that photo's own
|
||||||
// request owns the viewer now.
|
// request owns the viewer now.
|
||||||
if *viewer.uid.borrow() != uid {
|
if viewer.load_generation.get() != generation {
|
||||||
|
if let Ok(Ok(Response::GalleryVideo { token, .. })) = result {
|
||||||
|
close_video(&ui, token);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
viewer.spinner.set_visible(false);
|
viewer.spinner.set_visible(false);
|
||||||
@@ -326,6 +335,14 @@ pub(crate) fn load_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>, uid: String) {
|
|||||||
viewer.status.set_visible(true);
|
viewer.status.set_visible(true);
|
||||||
};
|
};
|
||||||
let path = match result {
|
let path = match result {
|
||||||
|
Ok(Ok(Response::GalleryVideo { url, token, size })) => {
|
||||||
|
*viewer.video_token.borrow_mut() = Some(token);
|
||||||
|
viewer.video.set_file(Some(&gio::File::for_uri(&url)));
|
||||||
|
viewer.media.set_visible_child_name("video");
|
||||||
|
sync_strip(&viewer);
|
||||||
|
show_info(&viewer, Some(size), ExifInfo::default());
|
||||||
|
return;
|
||||||
|
}
|
||||||
Ok(Ok(Response::FilePath { path })) => path,
|
Ok(Ok(Response::FilePath { path })) => path,
|
||||||
Ok(Ok(Response::Error { message, .. })) => return fail(&message),
|
Ok(Ok(Response::Error { message, .. })) => return fail(&message),
|
||||||
Ok(Ok(_)) => return fail(&gettext("Unexpected reply from the Proton Drive service.")),
|
Ok(Ok(_)) => return fail(&gettext("Unexpected reply from the Proton Drive service.")),
|
||||||
@@ -481,8 +498,18 @@ fn next_slide(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
|||||||
|
|
||||||
/// Stop whatever the player was playing, so stepping off a video (or closing
|
/// Stop whatever the player was playing, so stepping off a video (or closing
|
||||||
/// the lightbox) doesn't leave its sound running.
|
/// the lightbox) doesn't leave its sound running.
|
||||||
fn stop_video(viewer: &Rc<Viewer>) {
|
fn close_video(ui: &Ui, token: String) {
|
||||||
|
let _reply = spawn_request(
|
||||||
|
ui.dirs.control_socket(),
|
||||||
|
Request::CloseGalleryVideo { token },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stop_video(ui: &Ui, viewer: &Rc<Viewer>) {
|
||||||
viewer.video.set_media_stream(gtk4::MediaStream::NONE);
|
viewer.video.set_media_stream(gtk4::MediaStream::NONE);
|
||||||
|
if let Some(token) = viewer.video_token.borrow_mut().take() {
|
||||||
|
close_video(ui, token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Warm the cache with the photo `delta` steps away, so stepping there is
|
/// Warm the cache with the photo `delta` steps away, so stepping there is
|
||||||
@@ -1473,6 +1500,8 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
|||||||
scroller: scroller.clone(),
|
scroller: scroller.clone(),
|
||||||
picture: picture.clone(),
|
picture: picture.clone(),
|
||||||
video,
|
video,
|
||||||
|
video_token: RefCell::new(None),
|
||||||
|
load_generation: Cell::new(0),
|
||||||
spinner,
|
spinner,
|
||||||
status: status_label,
|
status: status_label,
|
||||||
title: title_label,
|
title: title_label,
|
||||||
@@ -1700,7 +1729,10 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
|||||||
}
|
}
|
||||||
if let Some(viewer) = keep.borrow_mut().take() {
|
if let Some(viewer) = keep.borrow_mut().take() {
|
||||||
reveal_photo(&ui_close, &viewer.uid.borrow());
|
reveal_photo(&ui_close, &viewer.uid.borrow());
|
||||||
stop_video(&viewer);
|
viewer
|
||||||
|
.load_generation
|
||||||
|
.set(viewer.load_generation.get().wrapping_add(1));
|
||||||
|
stop_video(&ui_close, &viewer);
|
||||||
disarm_slide(&viewer);
|
disarm_slide(&viewer);
|
||||||
if let Some(source) = viewer.chrome_source.borrow_mut().take() {
|
if let Some(source) = viewer.chrome_source.borrow_mut().take() {
|
||||||
source.remove();
|
source.remove();
|
||||||
@@ -1952,7 +1984,7 @@ fn open_viewer_menu(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
|||||||
}
|
}
|
||||||
menu.section();
|
menu.section();
|
||||||
// These need the full-size file, which may still be downloading.
|
// These need the full-size file, which may still be downloading.
|
||||||
if viewer.path.borrow().is_some() {
|
if viewer.path.borrow().is_some() || viewer.video_token.borrow().is_some() {
|
||||||
let still = viewer.media.visible_child_name().as_deref() == Some("photo");
|
let still = viewer.media.visible_child_name().as_deref() == Some("photo");
|
||||||
if still {
|
if still {
|
||||||
// Translators: menu item that puts the photo on the clipboard as an image.
|
// Translators: menu item that puts the photo on the clipboard as an image.
|
||||||
@@ -1999,17 +2031,45 @@ fn open_viewer_menu(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_shown_photo(_ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
fn save_shown_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||||
if let Some(path) = viewer.path.borrow().as_deref() {
|
with_viewer_file(ui, viewer, |viewer, path, name| {
|
||||||
let name = viewer.name.borrow();
|
save_photo_to_disk(viewer, path, name.unwrap_or("photo"))
|
||||||
save_photo_to_disk(viewer, path, name.as_deref().unwrap_or("photo"));
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_shown_photo(_ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
fn open_shown_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||||
|
with_viewer_file(ui, viewer, |viewer, path, name| {
|
||||||
|
open_with(&viewer.window, path, name)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_viewer_file(
|
||||||
|
ui: &Rc<Ui>,
|
||||||
|
viewer: &Rc<Viewer>,
|
||||||
|
use_file: impl FnOnce(&Rc<Viewer>, &str, Option<&str>) + 'static,
|
||||||
|
) {
|
||||||
|
let name = viewer.name.borrow().clone();
|
||||||
if let Some(path) = viewer.path.borrow().as_deref() {
|
if let Some(path) = viewer.path.borrow().as_deref() {
|
||||||
open_with(&viewer.window, path, viewer.name.borrow().as_deref());
|
use_file(viewer, path, name.as_deref());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if viewer.video_token.borrow().is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let uid = viewer.uid.borrow().clone();
|
||||||
|
let viewer = viewer.clone();
|
||||||
|
let rx = spawn_request(ui.dirs.control_socket(), Request::OpenPhoto { uid });
|
||||||
|
glib::spawn_future_local(async move {
|
||||||
|
match rx.recv().await {
|
||||||
|
Ok(Ok(Response::FilePath { path })) => use_file(&viewer, &path, name.as_deref()),
|
||||||
|
Ok(Ok(Response::Error { message, .. })) => {
|
||||||
|
viewer.toasts.add_toast(adw::Toast::new(&message))
|
||||||
|
}
|
||||||
|
_ => viewer
|
||||||
|
.toasts
|
||||||
|
.add_toast(adw::Toast::new(&gettext("Couldn't open the file."))),
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_shown_photo_to_album(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
fn add_shown_photo_to_album(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||||
|
|||||||
@@ -467,6 +467,7 @@ impl GalleryRow {
|
|||||||
|
|
||||||
/// The widgets [`build_gallery_page`] hands back to [`build_window`].
|
/// The widgets [`build_gallery_page`] hands back to [`build_window`].
|
||||||
pub(crate) struct GalleryWidgets {
|
pub(crate) struct GalleryWidgets {
|
||||||
|
pub(crate) drive_galleries: gtk4::Button,
|
||||||
/// Flat, newest-first list of every loaded photo. Backs the lightbox's
|
/// Flat, newest-first list of every loaded photo. Backs the lightbox's
|
||||||
/// prev/next navigation; the visible sections are derived from it.
|
/// prev/next navigation; the visible sections are derived from it.
|
||||||
pub(crate) model: gio::ListStore,
|
pub(crate) model: gio::ListStore,
|
||||||
@@ -940,10 +941,13 @@ pub(crate) fn build_gallery_page() -> (gtk4::Widget, GalleryWidgets) {
|
|||||||
header.pack_end(&more);
|
header.pack_end(&more);
|
||||||
header.pack_end(&select_btn);
|
header.pack_end(&select_btn);
|
||||||
header.pack_end(&selection.cancel);
|
header.pack_end(&selection.cancel);
|
||||||
|
let drive_galleries = gtk4::Button::with_label(&gettext("Drive Galleries"));
|
||||||
|
header.pack_end(&drive_galleries);
|
||||||
|
|
||||||
(
|
(
|
||||||
frame.upcast(),
|
frame.upcast(),
|
||||||
GalleryWidgets {
|
GalleryWidgets {
|
||||||
|
drive_galleries,
|
||||||
model,
|
model,
|
||||||
groups,
|
groups,
|
||||||
content,
|
content,
|
||||||
@@ -2203,16 +2207,15 @@ pub(crate) fn justify_rows(ui: &Rc<Ui>, photos: &[PhotoItem], width: i32) -> Vec
|
|||||||
/// The narrowest and the widest shape a tile may take, as width over height.
|
/// The narrowest and the widest shape a tile may take, as width over height.
|
||||||
/// A panorama at its own shape would be a ribbon, and a screenshot of a phone
|
/// A panorama at its own shape would be a ribbon, and a screenshot of a phone
|
||||||
/// a thread; past these the thumbnail is cropped to fit.
|
/// a thread; past these the thumbnail is cropped to fit.
|
||||||
pub(crate) const TILE_RATIO_MIN: f64 = 0.5;
|
#[cfg(test)]
|
||||||
pub(crate) const TILE_RATIO_MAX: f64 = 2.5;
|
const TILE_RATIO_MIN: f64 = 0.5;
|
||||||
|
#[cfg(test)]
|
||||||
|
const TILE_RATIO_MAX: f64 = 2.5;
|
||||||
|
|
||||||
/// The shape a photo's tile takes: its own, clamped, or square while the
|
/// The shape a photo's tile takes: its own, clamped, or square while the
|
||||||
/// daemon has not seen a thumbnail of it yet.
|
/// daemon has not seen a thumbnail of it yet.
|
||||||
pub(crate) fn tile_ratio(ratio: Option<f64>) -> f64 {
|
pub(crate) fn tile_ratio(ratio: Option<f64>) -> f64 {
|
||||||
ratio
|
pg_core::grid::tile_ratio(ratio.unwrap_or(1.0))
|
||||||
.filter(|ratio| ratio.is_finite() && *ratio > 0.0)
|
|
||||||
.unwrap_or(1.0)
|
|
||||||
.clamp(TILE_RATIO_MIN, TILE_RATIO_MAX)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The justified layout math: tiles of the given shapes, in order, broken into
|
/// The justified layout math: tiles of the given shapes, in order, broken into
|
||||||
@@ -2225,64 +2228,33 @@ pub(crate) fn tile_ratio(ratio: Option<f64>) -> f64 {
|
|||||||
/// two photos from one day stay two photos at the target height, not two
|
/// two photos from one day stay two photos at the target height, not two
|
||||||
/// photos as tall as the window.
|
/// photos as tall as the window.
|
||||||
pub(crate) fn plan_justified(ratios: &[f64], width: i32, target: i32) -> Vec<Vec<(i32, i32)>> {
|
pub(crate) fn plan_justified(ratios: &[f64], width: i32, target: i32) -> Vec<Vec<(i32, i32)>> {
|
||||||
let width = width.max(1);
|
let Ok(grid) = pg_core::grid::plan_sections(
|
||||||
let target = f64::from(target.clamp(ROW_MIN, ROW_MAX));
|
ratios,
|
||||||
let gap = f64::from(TILE_GAP);
|
&[],
|
||||||
// The height that makes `ratios` span the width exactly.
|
width.clamp(1, 32_768) as u32,
|
||||||
let fit = |ratios: &[f64]| {
|
target.clamp(ROW_MIN, ROW_MAX) as u32,
|
||||||
let gaps = gap * (ratios.len() as f64 - 1.0);
|
TILE_GAP as u32,
|
||||||
(f64::from(width) - gaps).max(1.0) / ratios.iter().sum::<f64>()
|
) else {
|
||||||
|
return Vec::new();
|
||||||
};
|
};
|
||||||
let mut rows = Vec::new();
|
let ends = grid
|
||||||
let mut start = 0;
|
.row_starts
|
||||||
while start < ratios.len() {
|
.iter()
|
||||||
let mut end = start + 1;
|
.copied()
|
||||||
while end < ratios.len() && fit(&ratios[start..end]) > target {
|
.skip(1)
|
||||||
end += 1;
|
.chain(std::iter::once(grid.widths.len() as u32));
|
||||||
}
|
grid.row_starts
|
||||||
let full = fit(&ratios[start..end]) <= target;
|
.iter()
|
||||||
// Giving the last photo back leaves the row taller than the target;
|
.copied()
|
||||||
// keeping it, shorter. Whichever misses by less wins.
|
.zip(ends)
|
||||||
if full
|
.zip(grid.row_heights)
|
||||||
&& end - start > 1
|
.map(|((start, end), height)| {
|
||||||
&& fit(&ratios[start..end - 1]) - target < target - fit(&ratios[start..end])
|
grid.widths[start as usize..end as usize]
|
||||||
{
|
.iter()
|
||||||
end -= 1;
|
.map(|width| (*width as i32, height as i32))
|
||||||
}
|
.collect()
|
||||||
let row = &ratios[start..end];
|
})
|
||||||
rows.push(if full {
|
.collect()
|
||||||
size_row(row, fit(row), Some(width))
|
|
||||||
} else {
|
|
||||||
size_row(row, target, None)
|
|
||||||
});
|
|
||||||
start = end;
|
|
||||||
}
|
|
||||||
rows
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Tile sizes for one row of shapes at `height`. With `span`, the widths are
|
|
||||||
/// rounded so the row, gaps included, is exactly that wide: each tile ends
|
|
||||||
/// where its share of the row ends, so no rounding error piles up at the end.
|
|
||||||
fn size_row(ratios: &[f64], height: f64, span: Option<i32>) -> Vec<(i32, i32)> {
|
|
||||||
let tile_height = (height.round() as i32).max(1);
|
|
||||||
let Some(span) = span else {
|
|
||||||
return ratios
|
|
||||||
.iter()
|
|
||||||
.map(|ratio| (((ratio * height).round() as i32).max(1), tile_height))
|
|
||||||
.collect();
|
|
||||||
};
|
|
||||||
let content = f64::from(span - TILE_GAP * (ratios.len() as i32 - 1));
|
|
||||||
let total: f64 = ratios.iter().sum();
|
|
||||||
let mut sizes = Vec::with_capacity(ratios.len());
|
|
||||||
let mut done = 0.0;
|
|
||||||
let mut left = 0;
|
|
||||||
for ratio in ratios {
|
|
||||||
done += ratio;
|
|
||||||
let right = (content * done / total).round() as i32;
|
|
||||||
sizes.push(((right - left).max(1), tile_height));
|
|
||||||
left = right;
|
|
||||||
}
|
|
||||||
sizes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The layout math: how many square tiles of about `target` px fit across
|
/// The layout math: how many square tiles of about `target` px fit across
|
||||||
|
|||||||
@@ -419,6 +419,10 @@ impl Tray for DriveTray {
|
|||||||
self.state.phase.icon().into()
|
self.state.phase.icon().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn attention_icon_name(&self) -> String {
|
||||||
|
self.icon_name()
|
||||||
|
}
|
||||||
|
|
||||||
fn status(&self) -> Status {
|
fn status(&self) -> Status {
|
||||||
match self.state.phase {
|
match self.state.phase {
|
||||||
Phase::Attention | Phase::SessionExpired => Status::NeedsAttention,
|
Phase::Attention | Phase::SessionExpired => Status::NeedsAttention,
|
||||||
@@ -672,6 +676,22 @@ mod tests {
|
|||||||
assert_eq!(phase_of(false, 0, true, false), Phase::Synced);
|
assert_eq!(phase_of(false, 0, true, false), Phase::Synced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn attention_states_supply_the_icon_the_tray_requests() {
|
||||||
|
let mut tray = DriveTray {
|
||||||
|
state: status_state(&status(""), &[], &[], Path::new("/m")),
|
||||||
|
socket: PathBuf::new(),
|
||||||
|
};
|
||||||
|
for (phase, icon) in [
|
||||||
|
(Phase::Attention, "dialog-warning-symbolic"),
|
||||||
|
(Phase::SessionExpired, "dialog-password-symbolic"),
|
||||||
|
] {
|
||||||
|
tray.state.phase = phase;
|
||||||
|
assert_eq!(tray.status(), Status::NeedsAttention);
|
||||||
|
assert_eq!(tray.attention_icon_name(), icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn status(extra: &str) -> Response {
|
fn status(extra: &str) -> Response {
|
||||||
status_from(env!("CARGO_PKG_VERSION"), extra)
|
status_from(env!("CARGO_PKG_VERSION"), extra)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -988,11 +988,16 @@ timing.
|
|||||||
**Where:** not located; the drain's conflict check in `crates/pdfs-fuse/src/drain.rs` is the
|
**Where:** not located; the drain's conflict check in `crates/pdfs-fuse/src/drain.rs` is the
|
||||||
first suspect
|
first suspect
|
||||||
|
|
||||||
**Repro:** Only the CI run above. The last steps created `x/z/y/a.txt` (37 bytes), wrote 42
|
**Repro:** The first CI failure created `x/z/y/a.txt` (37 bytes), wrote 42
|
||||||
bytes into it at offset 20, and brought every link up. Drive then held the file at its first
|
bytes into it at offset 20, and brought every link up. Drive then held the file at its first
|
||||||
37 bytes, and the full content was in `x/z/y/a (sync-conflict …).txt`. No other client wrote
|
37 bytes, and the full content was in `x/z/y/a (sync-conflict …).txt`. No other client wrote
|
||||||
to it.
|
to it.
|
||||||
|
|
||||||
|
On 2026-11-19, seed 1 of `one-client-echoes` showed the same symptom with delayed,
|
||||||
|
duplicated, and reordered events. A two-byte overwrite of `x/d` appeared only in a
|
||||||
|
conflict copy. Local replays passed. The simulation now retains its operation trace
|
||||||
|
and daemon logs on failure. [CI run](https://github.com/narrrl/proton-drive-linux/actions/runs/44427290348)
|
||||||
|
|
||||||
**Cause.** Not known. Nothing was lost, since the conflict copy holds the bytes, but the file
|
**Cause.** Not known. Nothing was lost, since the conflict copy holds the bytes, but the file
|
||||||
conflicted with its own create. B183 and B184 found the same symptom after a lost create
|
conflicted with its own create. B183 and B184 found the same symptom after a lost create
|
||||||
reply.
|
reply.
|
||||||
|
|||||||
@@ -11,6 +11,38 @@ scratch (user data in `staging/` and `recovery/` is never touched by this).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Open **Drive Galleries** from Photos to browse saved My files folders and their
|
||||||
|
subfolders, choose album covers, and manage public links. Saved galleries and
|
||||||
|
covers sync with Proton Gallery on desktop and Android.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Photos uses Proton Gallery's justified row planner. The Photos viewer starts
|
||||||
|
and seeks through supported videos without caching the whole original.
|
||||||
|
- Gallery-hidden albums and their contents are filtered from Photos and Drive
|
||||||
|
Galleries. Unlock them with the local Gallery passphrase.
|
||||||
|
|
||||||
|
## [3.8.1] — 2026-11-19
|
||||||
|
|
||||||
|
Schema: **45**. No database migration in this release.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Refreshed the application icon and project artwork, and updated the documentation screenshots.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The cache skips pinned files when looking for space to reclaim and reapplies the configured
|
||||||
|
limit when the service starts. Pinned files and recovery data are preserved.
|
||||||
|
- Trashing a folder waits for queued moves out of it, including moves from nested subfolders.
|
||||||
|
If a move is blocked by an item or folder already in Trash, Sync and `pdfs sync issues`
|
||||||
|
identify what to restore before retrying.
|
||||||
|
- The system tray displays a warning icon when sync needs attention or the session has expired.
|
||||||
|
- Updated the Proton SDK to 0.12.1 so a fast local clock no longer causes Proton to reject
|
||||||
|
uploads of new files and photos.
|
||||||
|
|
||||||
## [3.8.0] — 2026-11-14
|
## [3.8.0] — 2026-11-14
|
||||||
|
|
||||||
Schema: **45**. Synced folders now tell device backups apart from folders attached to My files.
|
Schema: **45**. Synced folders now tell device backups apart from folders attached to My files.
|
||||||
@@ -2353,6 +2385,7 @@ First stable release: FUSE files-on-demand mount, sync daemon under `proton-driv
|
|||||||
- The outstanding FUSE defects tracked in `docs/BUGS.md`, plus a truncate defect, validated
|
- The outstanding FUSE defects tracked in `docs/BUGS.md`, plus a truncate defect, validated
|
||||||
by a new POSIX compliance suite for the filesystem.
|
by a new POSIX compliance suite for the filesystem.
|
||||||
|
|
||||||
|
[3.8.1]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.8.1
|
||||||
[3.5.0]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.5.0
|
[3.5.0]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.5.0
|
||||||
[3.4.1]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.4.1
|
[3.4.1]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.4.1
|
||||||
[3.4.0]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.4.0
|
[3.4.0]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.4.0
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ invented account, so they never show anyone's files:
|
|||||||
```bash
|
```bash
|
||||||
scripts/screenshots.sh # all of them, into images/
|
scripts/screenshots.sh # all of them, into images/
|
||||||
scripts/screenshots.sh --only photos,files # just these
|
scripts/screenshots.sh --only photos,files # just these
|
||||||
|
scripts/screenshots.sh --debug --skip-build # reuse already-built debug binaries
|
||||||
scripts/screenshots.sh --website ../proton-drive-linux-website # and copy them to the website
|
scripts/screenshots.sh --website ../proton-drive-linux-website # and copy them to the website
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ PDFS_SIM_SEED=7 RUST_LOG=pdfs_fuse=debug cargo test -p pdfs-fuse --lib \
|
|||||||
| `PDFS_SIM_MEASURE` | Run `a_thousand_files_drain_as_fast_on_wifi_as_on_lan`, which times 1,000 files in 100 folders on a LAN and a Wi-Fi profile and prints the times |
|
| `PDFS_SIM_MEASURE` | Run `a_thousand_files_drain_as_fast_on_wifi_as_on_lan`, which times 1,000 files in 100 folders on a LAN and a Wi-Fi profile and prints the times |
|
||||||
|
|
||||||
A failure is a seed that can be replayed, but the daemon uses real threads, so a race may need
|
A failure is a seed that can be replayed, but the daemon uses real threads, so a race may need
|
||||||
several replays. In CI, the `simulation` job uploads the stacks of a hung run as an artifact.
|
several replays. In CI, the `simulation` job uploads the failed seed's steps and daemon logs,
|
||||||
|
along with thread stacks when the watchdog catches a hang.
|
||||||
|
|
||||||
## Acceptance suite
|
## Acceptance suite
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# Violet / Copper vector branding
|
||||||
|
|
||||||
|
Drive, Stream, and Gallery share frontal violet–pink faces, shallow metallic copper backing, and narrow edge highlights. The icons are editable vector artwork with no embedded images or raster effects.
|
||||||
|
|
||||||
|
| App | Mark |
|
||||||
|
| --- | --- |
|
||||||
|
| Proton Drive for Linux | Open folder with lilac documents |
|
||||||
|
| Proton Stream | Rounded play prism |
|
||||||
|
| Proton Gallery | Stacked photo plates, mountains, and a copper sun |
|
||||||
|
|
||||||
|
## Master artwork
|
||||||
|
|
||||||
|
Edit `images/logo.svg`. It uses a 256-unit grid with transparent margins, a `mark` group, and reusable linear gradients. The copper backing extends six units up and right. SVG paths, rounded rectangles, circles, strokes, translation, and the photo clip are retained when exporting Android VectorDrawables. Unsupported SVG features cause generation to fail rather than silently change the artwork.
|
||||||
|
|
||||||
|
Earlier artwork is preserved in `images/branding-archive/`. The new assets replace the active branding without removing previous designs.
|
||||||
|
|
||||||
|
## Regeneration
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python scripts/render-branding.py
|
||||||
|
python scripts/render-branding.py --check
|
||||||
|
```
|
||||||
|
|
||||||
|
Requires Python 3, librsvg (`rsvg-convert`), and ImageMagick (`magick`). Stream's TV banner also requires fontconfig and DejaVu Sans. Keep the generator identical across the three repositories; every checkout renders independently and requires no sibling checkout. Edit the canonical master rather than generated platform assets.
|
||||||
|
|
||||||
|
## Platform treatment
|
||||||
|
|
||||||
|
- Desktop SVGs and PNGs retain transparent margins and the exact approved geometry. The same colored artwork works on light and dark surfaces.
|
||||||
|
- Android adaptive icons use a pale lavender full-bleed background and a separate foreground containing the complete object. The 256-unit canvas maps to the central 64dp of the 108dp adaptive canvas; the painted geometry stays within the central safe circle. Android supplies the outer mask.
|
||||||
|
- Themed launcher icons and Stream's status-bar notification icon use a white silhouette without colored bevel highlights.
|
||||||
|
- iOS uses the same play prism over an opaque pale lavender square, exported at 1024px. The system supplies the corner mask.
|
||||||
|
- The Android TV banner pairs the play prism with the full Proton Stream name.
|
||||||
|
|
||||||
|
Keep full product names in launcher metadata. Application UI typography and photo-content icons are independent of this branding.
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
`packaging/io.narl.proton-drive-linux.svg` is installed by the desktop packages and embedded in the GTK resource bundle for in-app branding.
|
||||||
|
|
||||||
|
The Drive cover (`images/cover.svg` and `images/cover.png`) also embeds the canonical icon. The generator updates its `app-logo` group while preserving the surrounding cover layout.
|
||||||
|
After Width: | Height: | Size: 363 KiB |
@@ -0,0 +1,156 @@
|
|||||||
|
<svg width="1920" height="1080" viewBox="0 0 1920 1080" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="bg" x1="0" y1="0" x2="1920" y2="1080" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#1A1240"/>
|
||||||
|
<stop offset="1" stop-color="#0A0618"/>
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient id="glow1" cx="1390" cy="520" r="640" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#6D4AFF" stop-opacity="0.55"/>
|
||||||
|
<stop offset="0.5" stop-color="#6D4AFF" stop-opacity="0.15"/>
|
||||||
|
<stop offset="1" stop-color="#6D4AFF" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
<radialGradient id="glow2" cx="160" cy="1080" r="700" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#A855F7" stop-opacity="0.25"/>
|
||||||
|
<stop offset="1" stop-color="#A855F7" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
<pattern id="dots" width="32" height="32" patternUnits="userSpaceOnUse">
|
||||||
|
<circle cx="2" cy="2" r="1.6" fill="#FFFFFF"/>
|
||||||
|
</pattern>
|
||||||
|
<radialGradient id="dotfade" cx="1390" cy="520" r="900" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#FFFFFF" stop-opacity="1"/>
|
||||||
|
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
<mask id="dotmask" maskUnits="userSpaceOnUse" x="0" y="0" width="1920" height="1080">
|
||||||
|
<rect width="1920" height="1080" fill="url(#dotfade)"/>
|
||||||
|
</mask>
|
||||||
|
<linearGradient id="title2" x1="140" y1="0" x2="760" y2="0" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#C9BBFF"/>
|
||||||
|
<stop offset="1" stop-color="#8A6CFF"/>
|
||||||
|
</linearGradient>
|
||||||
|
|
||||||
|
<!-- app logo -->
|
||||||
|
<linearGradient id="pdl-face" x1="12" y1="12" x2="116" y2="112" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#A48BFF"/>
|
||||||
|
<stop offset="0.55" stop-color="#7552FF"/>
|
||||||
|
<stop offset="1" stop-color="#5B36F2"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="pdl-cloud" x1="0" y1="34" x2="0" y2="88" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#FFFFFF"/>
|
||||||
|
<stop offset="1" stop-color="#ECE6FF"/>
|
||||||
|
</linearGradient>
|
||||||
|
<mask id="pdl-cut" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||||
|
<g fill="#FFFFFF">
|
||||||
|
<circle cx="66" cy="57" r="23"/>
|
||||||
|
<circle cx="42" cy="68" r="16"/>
|
||||||
|
<circle cx="88" cy="69" r="15"/>
|
||||||
|
<rect x="26" y="68" width="77" height="20" rx="10"/>
|
||||||
|
</g>
|
||||||
|
<g stroke="#000000" stroke-width="7.5" stroke-linecap="round" stroke-linejoin="round" fill="none">
|
||||||
|
<path d="M64 49v26"/>
|
||||||
|
<path d="M54.5 65.5l9.5 9.5 9.5-9.5"/>
|
||||||
|
</g>
|
||||||
|
</mask>
|
||||||
|
<filter id="logoshadow" x="-50%" y="-50%" width="200%" height="200%">
|
||||||
|
<feGaussianBlur stdDeviation="6"/>
|
||||||
|
</filter>
|
||||||
|
<filter id="chipshadow" x="-50%" y="-50%" width="200%" height="200%">
|
||||||
|
<feGaussianBlur stdDeviation="14"/>
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<!-- background -->
|
||||||
|
<rect width="1920" height="1080" fill="url(#bg)"/>
|
||||||
|
<rect width="1920" height="1080" fill="url(#glow2)"/>
|
||||||
|
<rect width="1920" height="1080" fill="url(#glow1)"/>
|
||||||
|
<rect width="1920" height="1080" fill="url(#dots)" opacity="0.07" mask="url(#dotmask)"/>
|
||||||
|
|
||||||
|
<!-- orbit rings -->
|
||||||
|
<g fill="none" stroke="#FFFFFF">
|
||||||
|
<circle cx="1390" cy="520" r="300" stroke-opacity="0.10" stroke-width="2"/>
|
||||||
|
<circle cx="1390" cy="520" r="420" stroke-opacity="0.06" stroke-width="2" stroke-dasharray="4 14" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<!-- logo, 128 -> 384 -->
|
||||||
|
<g transform="translate(1198 328) scale(3)">
|
||||||
|
<rect x="16" y="24" width="96" height="92" rx="24" fill="#2A1080" opacity="0.8" filter="url(#logoshadow)"/>
|
||||||
|
<rect x="12" y="16" width="104" height="100" rx="26" fill="#4424C0"/>
|
||||||
|
<rect x="12" y="12" width="104" height="100" rx="26" fill="url(#pdl-face)"/>
|
||||||
|
<rect x="12.5" y="12.5" width="103" height="99" rx="25.5" fill="none" stroke="#FFFFFF" stroke-opacity="0.2"/>
|
||||||
|
<rect y="3" width="128" height="128" fill="#2E1596" fill-opacity="0.3" mask="url(#pdl-cut)"/>
|
||||||
|
<rect width="128" height="128" fill="url(#pdl-cloud)" mask="url(#pdl-cut)"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<!-- feature chips around the logo -->
|
||||||
|
<g font-family="Adwaita Sans" font-size="26" font-weight="600" fill="#FFFFFF">
|
||||||
|
<!-- folder, top left -->
|
||||||
|
<g transform="translate(1000 200)">
|
||||||
|
<rect x="0" y="10" width="236" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
||||||
|
<rect x="0" y="0" width="236" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
||||||
|
<g transform="translate(22 20)">
|
||||||
|
<rect width="36" height="36" rx="10" fill="#6D4AFF"/>
|
||||||
|
<path d="M8 13a2 2 0 0 1 2-2h5l2.5 2.5H26a2 2 0 0 1 2 2V25a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2z" fill="#FFFFFF"/>
|
||||||
|
</g>
|
||||||
|
<text x="74" y="47">On demand</text>
|
||||||
|
</g>
|
||||||
|
<!-- sync, top right -->
|
||||||
|
<g transform="translate(1590 290)">
|
||||||
|
<rect x="0" y="10" width="164" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
||||||
|
<rect x="0" y="0" width="164" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
||||||
|
<g transform="translate(22 20)">
|
||||||
|
<rect width="36" height="36" rx="10" fill="#1EA885"/>
|
||||||
|
<g fill="none" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M26 15a8.5 8.5 0 0 0-15-2"/>
|
||||||
|
<path d="M10 9v4.5h4.5"/>
|
||||||
|
<path d="M10 21a8.5 8.5 0 0 0 15 2"/>
|
||||||
|
<path d="M26 27v-4.5h-4.5"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text x="74" y="47">Sync</text>
|
||||||
|
</g>
|
||||||
|
<!-- photos, bottom right -->
|
||||||
|
<g transform="translate(1560 690)">
|
||||||
|
<rect x="0" y="10" width="206" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
||||||
|
<rect x="0" y="0" width="206" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
||||||
|
<g transform="translate(22 20)">
|
||||||
|
<rect width="36" height="36" rx="10" fill="#E8618C"/>
|
||||||
|
<rect x="8" y="9" width="20" height="18" rx="3" fill="none" stroke="#FFFFFF" stroke-width="2.4"/>
|
||||||
|
<circle cx="14" cy="15" r="2" fill="#FFFFFF"/>
|
||||||
|
<path d="M9.5 25l6-6 4 4 3-3 4 4" fill="none" stroke="#FFFFFF" stroke-width="2.4" stroke-linejoin="round"/>
|
||||||
|
</g>
|
||||||
|
<text x="74" y="47">Photos</text>
|
||||||
|
</g>
|
||||||
|
<!-- terminal, bottom left -->
|
||||||
|
<g transform="translate(980 790)">
|
||||||
|
<rect x="0" y="10" width="206" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
||||||
|
<rect x="0" y="0" width="206" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
||||||
|
<g transform="translate(22 20)">
|
||||||
|
<rect width="36" height="36" rx="10" fill="#3B3F5C"/>
|
||||||
|
<path d="M9 12l6 6-6 6" fill="none" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path d="M18 25h9" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
|
<text x="74" y="48" font-family="JetBrainsMono NF" font-size="25" font-weight="700">pdfs</text>
|
||||||
|
<text x="150" y="48" font-weight="500" fill="#B9B0D9">CLI</text>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<!-- text block -->
|
||||||
|
<g font-family="Adwaita Sans">
|
||||||
|
<g transform="translate(140 292)">
|
||||||
|
<rect width="410" height="48" rx="24" fill="#6D4AFF" fill-opacity="0.18" stroke="#8A6CFF" stroke-opacity="0.6" stroke-width="1.5"/>
|
||||||
|
<circle cx="28" cy="24" r="6" fill="#A48BFF"/>
|
||||||
|
<text x="46" y="32" font-size="21" font-weight="700" letter-spacing="2.4" fill="#D6CCFF">UNOFFICIAL · OPEN SOURCE</text>
|
||||||
|
</g>
|
||||||
|
<text x="134" y="478" font-size="124" font-weight="800" letter-spacing="-3" fill="#FFFFFF">Proton Drive</text>
|
||||||
|
<text x="134" y="610" font-size="124" font-weight="800" letter-spacing="-3" fill="url(#title2)">for Linux</text>
|
||||||
|
<text x="140" y="702" font-size="38" font-weight="400" fill="#B9B0D9">Your Drive as a folder, and a native GTK4 app.</text>
|
||||||
|
<text x="140" y="752" font-size="38" font-weight="400" fill="#B9B0D9">No Electron.</text>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<!-- footer -->
|
||||||
|
<g font-family="JetBrainsMono NF" font-size="24" fill="#8C83B0">
|
||||||
|
<text x="140" y="968">github.com/narrrl/proton-drive-linux</text>
|
||||||
|
</g>
|
||||||
|
<g font-family="Adwaita Sans" font-size="22" fill="#6F6894">
|
||||||
|
<text x="1780" y="968" text-anchor="end">Not affiliated with Proton AG</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 8.3 KiB |
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"
|
||||||
|
role="img" aria-label="Proton Drive for Linux" data-app="drive">
|
||||||
|
<title>Proton Drive for Linux</title>
|
||||||
|
<desc>A custom faceted D with an inset mount channel, in violet warming to copper.</desc>
|
||||||
|
<!-- Canonical artwork. Regenerate platform assets with scripts/render-branding.py. -->
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="18" y1="12" x2="112" y2="116" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#F6F2FC"/>
|
||||||
|
<stop offset="1" stop-color="#E5DDEE"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="material" x1="31" y1="35" x2="96" y2="95" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#9170E2"/>
|
||||||
|
<stop offset=".38" stop-color="#6D4AFF"/>
|
||||||
|
<stop offset=".6" stop-color="#7044D1"/>
|
||||||
|
<stop offset=".82" stop-color="#A66598"/>
|
||||||
|
<stop offset="1" stop-color="#B56D51"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect x="12" y="12" width="104" height="104" rx="27" fill="url(#face)"/>
|
||||||
|
<rect x="12.75" y="12.75" width="102.5" height="102.5" rx="26.25"
|
||||||
|
fill="none" stroke="#A18CB7" stroke-width="1.5"/>
|
||||||
|
<g id="mark">
|
||||||
|
<path d="M 43.32 33.92 H 64.94 C 73.4 33.92 80.92 36.74 86.56 42.38 L 96.9 52.72 C 103.48 59.3 103.48 68.7 96.9 75.28 L 86.56 85.62 C 80.92 91.26 73.4 94.08 64.94 94.08 H 43.32 C 38.15 94.08 33.92 89.85 33.92 84.68 V 75.28 H 47.08 V 79.04 C 47.08 80.074 47.926 80.92 48.96 80.92 H 64.94 C 69.64 80.92 73.4 79.04 77.16 75.28 L 85.62 66.82 C 87.218 65.222 87.218 62.778 85.62 61.18 L 77.16 52.72 C 73.4 48.96 69.64 47.08 64.94 47.08 H 48.96 C 47.926 47.08 47.08 47.926 47.08 48.96 V 52.72 H 33.92 V 43.32 C 33.92 38.15 38.15 33.92 43.32 33.92 Z" fill="url(#material)" fill-rule="nonzero"/>
|
||||||
|
<path d="M 29.22 58.36 H 62.12 C 65.222 58.36 67.76 60.898 67.76 64 C 67.76 67.102 65.222 69.64 62.12 69.64 H 29.22 C 26.118 69.64 23.58 67.102 23.58 64 C 23.58 60.898 26.118 58.36 29.22 58.36 Z" fill="url(#material)" fill-rule="nonzero"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 138 KiB |
|
Before Width: | Height: | Size: 363 KiB After Width: | Height: | Size: 407 KiB |
@@ -1,156 +1,164 @@
|
|||||||
<svg width="1920" height="1080" viewBox="0 0 1920 1080" xmlns="http://www.w3.org/2000/svg">
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<defs>
|
<!-- Generated by scripts/render-branding.py; edit images/logo.svg. -->
|
||||||
<linearGradient id="bg" x1="0" y1="0" x2="1920" y2="1080" gradientUnits="userSpaceOnUse">
|
<svg xmlns="http://www.w3.org/2000/svg" width="1920" height="1080" viewBox="0 0 1920 1080">
|
||||||
<stop offset="0" stop-color="#1A1240"/>
|
<defs>
|
||||||
<stop offset="1" stop-color="#0A0618"/>
|
<linearGradient id="bg" x1="0" y1="0" x2="1920" y2="1080" gradientUnits="userSpaceOnUse">
|
||||||
</linearGradient>
|
<stop offset="0" stop-color="#1A1240" />
|
||||||
<radialGradient id="glow1" cx="1390" cy="520" r="640" gradientUnits="userSpaceOnUse">
|
<stop offset="1" stop-color="#0A0618" />
|
||||||
<stop offset="0" stop-color="#6D4AFF" stop-opacity="0.55"/>
|
</linearGradient>
|
||||||
<stop offset="0.5" stop-color="#6D4AFF" stop-opacity="0.15"/>
|
<radialGradient id="glow1" cx="1390" cy="520" r="640" gradientUnits="userSpaceOnUse">
|
||||||
<stop offset="1" stop-color="#6D4AFF" stop-opacity="0"/>
|
<stop offset="0" stop-color="#6D4AFF" stop-opacity="0.55" />
|
||||||
</radialGradient>
|
<stop offset="0.5" stop-color="#6D4AFF" stop-opacity="0.15" />
|
||||||
<radialGradient id="glow2" cx="160" cy="1080" r="700" gradientUnits="userSpaceOnUse">
|
<stop offset="1" stop-color="#6D4AFF" stop-opacity="0" />
|
||||||
<stop offset="0" stop-color="#A855F7" stop-opacity="0.25"/>
|
</radialGradient>
|
||||||
<stop offset="1" stop-color="#A855F7" stop-opacity="0"/>
|
<radialGradient id="glow2" cx="160" cy="1080" r="700" gradientUnits="userSpaceOnUse">
|
||||||
</radialGradient>
|
<stop offset="0" stop-color="#A855F7" stop-opacity="0.25" />
|
||||||
<pattern id="dots" width="32" height="32" patternUnits="userSpaceOnUse">
|
<stop offset="1" stop-color="#A855F7" stop-opacity="0" />
|
||||||
<circle cx="2" cy="2" r="1.6" fill="#FFFFFF"/>
|
</radialGradient>
|
||||||
</pattern>
|
<pattern id="dots" width="32" height="32" patternUnits="userSpaceOnUse">
|
||||||
<radialGradient id="dotfade" cx="1390" cy="520" r="900" gradientUnits="userSpaceOnUse">
|
<circle cx="2" cy="2" r="1.6" fill="#FFFFFF" />
|
||||||
<stop offset="0" stop-color="#FFFFFF" stop-opacity="1"/>
|
</pattern>
|
||||||
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
<radialGradient id="dotfade" cx="1390" cy="520" r="900" gradientUnits="userSpaceOnUse">
|
||||||
</radialGradient>
|
<stop offset="0" stop-color="#FFFFFF" stop-opacity="1" />
|
||||||
<mask id="dotmask" maskUnits="userSpaceOnUse" x="0" y="0" width="1920" height="1080">
|
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0" />
|
||||||
<rect width="1920" height="1080" fill="url(#dotfade)"/>
|
</radialGradient>
|
||||||
</mask>
|
<mask id="dotmask" maskUnits="userSpaceOnUse" x="0" y="0" width="1920" height="1080">
|
||||||
<linearGradient id="title2" x1="140" y1="0" x2="760" y2="0" gradientUnits="userSpaceOnUse">
|
<rect width="1920" height="1080" fill="url(#dotfade)" />
|
||||||
<stop offset="0" stop-color="#C9BBFF"/>
|
</mask>
|
||||||
<stop offset="1" stop-color="#8A6CFF"/>
|
<linearGradient id="title2" x1="140" y1="0" x2="760" y2="0" gradientUnits="userSpaceOnUse">
|
||||||
</linearGradient>
|
<stop offset="0" stop-color="#C9BBFF" />
|
||||||
|
<stop offset="1" stop-color="#8A6CFF" />
|
||||||
<!-- app logo -->
|
</linearGradient>
|
||||||
<linearGradient id="pdl-face" x1="12" y1="12" x2="116" y2="112" gradientUnits="userSpaceOnUse">
|
<filter id="chipshadow" x="-50%" y="-50%" width="200%" height="200%">
|
||||||
<stop offset="0" stop-color="#A48BFF"/>
|
<feGaussianBlur stdDeviation="14" />
|
||||||
<stop offset="0.55" stop-color="#7552FF"/>
|
</filter>
|
||||||
<stop offset="1" stop-color="#5B36F2"/>
|
</defs>
|
||||||
</linearGradient>
|
<rect width="1920" height="1080" fill="url(#bg)" />
|
||||||
<linearGradient id="pdl-cloud" x1="0" y1="34" x2="0" y2="88" gradientUnits="userSpaceOnUse">
|
<rect width="1920" height="1080" fill="url(#glow2)" />
|
||||||
<stop offset="0" stop-color="#FFFFFF"/>
|
<rect width="1920" height="1080" fill="url(#glow1)" />
|
||||||
<stop offset="1" stop-color="#ECE6FF"/>
|
<rect width="1920" height="1080" fill="url(#dots)" opacity="0.07" mask="url(#dotmask)" />
|
||||||
</linearGradient>
|
<g fill="none" stroke="#FFFFFF">
|
||||||
<mask id="pdl-cut" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
<circle cx="1390" cy="520" r="300" stroke-opacity="0.10" stroke-width="2" />
|
||||||
<g fill="#FFFFFF">
|
<circle cx="1390" cy="520" r="420" stroke-opacity="0.06" stroke-width="2" stroke-dasharray="4 14" stroke-linecap="round" />
|
||||||
<circle cx="66" cy="57" r="23"/>
|
|
||||||
<circle cx="42" cy="68" r="16"/>
|
|
||||||
<circle cx="88" cy="69" r="15"/>
|
|
||||||
<rect x="26" y="68" width="77" height="20" rx="10"/>
|
|
||||||
</g>
|
|
||||||
<g stroke="#000000" stroke-width="7.5" stroke-linecap="round" stroke-linejoin="round" fill="none">
|
|
||||||
<path d="M64 49v26"/>
|
|
||||||
<path d="M54.5 65.5l9.5 9.5 9.5-9.5"/>
|
|
||||||
</g>
|
|
||||||
</mask>
|
|
||||||
<filter id="logoshadow" x="-50%" y="-50%" width="200%" height="200%">
|
|
||||||
<feGaussianBlur stdDeviation="6"/>
|
|
||||||
</filter>
|
|
||||||
<filter id="chipshadow" x="-50%" y="-50%" width="200%" height="200%">
|
|
||||||
<feGaussianBlur stdDeviation="14"/>
|
|
||||||
</filter>
|
|
||||||
</defs>
|
|
||||||
|
|
||||||
<!-- background -->
|
|
||||||
<rect width="1920" height="1080" fill="url(#bg)"/>
|
|
||||||
<rect width="1920" height="1080" fill="url(#glow2)"/>
|
|
||||||
<rect width="1920" height="1080" fill="url(#glow1)"/>
|
|
||||||
<rect width="1920" height="1080" fill="url(#dots)" opacity="0.07" mask="url(#dotmask)"/>
|
|
||||||
|
|
||||||
<!-- orbit rings -->
|
|
||||||
<g fill="none" stroke="#FFFFFF">
|
|
||||||
<circle cx="1390" cy="520" r="300" stroke-opacity="0.10" stroke-width="2"/>
|
|
||||||
<circle cx="1390" cy="520" r="420" stroke-opacity="0.06" stroke-width="2" stroke-dasharray="4 14" stroke-linecap="round"/>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- logo, 128 -> 384 -->
|
|
||||||
<g transform="translate(1198 328) scale(3)">
|
|
||||||
<rect x="16" y="24" width="96" height="92" rx="24" fill="#2A1080" opacity="0.8" filter="url(#logoshadow)"/>
|
|
||||||
<rect x="12" y="16" width="104" height="100" rx="26" fill="#4424C0"/>
|
|
||||||
<rect x="12" y="12" width="104" height="100" rx="26" fill="url(#pdl-face)"/>
|
|
||||||
<rect x="12.5" y="12.5" width="103" height="99" rx="25.5" fill="none" stroke="#FFFFFF" stroke-opacity="0.2"/>
|
|
||||||
<rect y="3" width="128" height="128" fill="#2E1596" fill-opacity="0.3" mask="url(#pdl-cut)"/>
|
|
||||||
<rect width="128" height="128" fill="url(#pdl-cloud)" mask="url(#pdl-cut)"/>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- feature chips around the logo -->
|
|
||||||
<g font-family="Adwaita Sans" font-size="26" font-weight="600" fill="#FFFFFF">
|
|
||||||
<!-- folder, top left -->
|
|
||||||
<g transform="translate(1000 200)">
|
|
||||||
<rect x="0" y="10" width="236" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
|
||||||
<rect x="0" y="0" width="236" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
|
||||||
<g transform="translate(22 20)">
|
|
||||||
<rect width="36" height="36" rx="10" fill="#6D4AFF"/>
|
|
||||||
<path d="M8 13a2 2 0 0 1 2-2h5l2.5 2.5H26a2 2 0 0 1 2 2V25a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2z" fill="#FFFFFF"/>
|
|
||||||
</g>
|
|
||||||
<text x="74" y="47">On demand</text>
|
|
||||||
</g>
|
</g>
|
||||||
<!-- sync, top right -->
|
<g id="app-logo" transform="translate(1198 328) scale(1.5)">
|
||||||
<g transform="translate(1590 290)">
|
<defs>
|
||||||
<rect x="0" y="10" width="164" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
<linearGradient id="drive-face" x1="36" y1="212" x2="220" y2="54" gradientUnits="userSpaceOnUse">
|
||||||
<rect x="0" y="0" width="164" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
<stop stop-color="#6240DA" />
|
||||||
<g transform="translate(22 20)">
|
<stop offset=".52" stop-color="#8056EF" />
|
||||||
<rect width="36" height="36" rx="10" fill="#1EA885"/>
|
<stop offset="1" stop-color="#D58BDF" />
|
||||||
<g fill="none" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round">
|
</linearGradient>
|
||||||
<path d="M26 15a8.5 8.5 0 0 0-15-2"/>
|
<linearGradient id="drive-rear" x1="26" y1="42" x2="218" y2="220" gradientUnits="userSpaceOnUse">
|
||||||
<path d="M10 9v4.5h4.5"/>
|
<stop stop-color="#8C68EE" />
|
||||||
<path d="M10 21a8.5 8.5 0 0 0 15 2"/>
|
<stop offset="1" stop-color="#5533B5" />
|
||||||
<path d="M26 27v-4.5h-4.5"/>
|
</linearGradient>
|
||||||
|
<linearGradient id="drive-paper" x1="60" y1="80" x2="180" y2="162" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#E7DFFA" />
|
||||||
|
<stop offset="1" stop-color="#BDA5EF" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="drive-copper" x1="32" y1="32" x2="232" y2="224" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#703E30" />
|
||||||
|
<stop offset=".16" stop-color="#B47456" />
|
||||||
|
<stop offset=".28" stop-color="#E6B296" />
|
||||||
|
<stop offset=".32" stop-color="#F8D8C3" />
|
||||||
|
<stop offset=".37" stop-color="#BB7C5A" />
|
||||||
|
<stop offset=".56" stop-color="#8A4D36" />
|
||||||
|
<stop offset=".69" stop-color="#D69B77" />
|
||||||
|
<stop offset=".75" stop-color="#F2C9AA" />
|
||||||
|
<stop offset=".81" stop-color="#B87956" />
|
||||||
|
<stop offset="1" stop-color="#713F30" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="drive-sun" x1="172" y1="82" x2="201" y2="112" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#8D513A" />
|
||||||
|
<stop offset=".33" stop-color="#DDA581" />
|
||||||
|
<stop offset=".47" stop-color="#F7D8B8" />
|
||||||
|
<stop offset=".53" stop-color="#D69B74" />
|
||||||
|
<stop offset="1" stop-color="#925439" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="drive-mountain" x1="44" y1="148" x2="186" y2="218" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#D9C9FA" />
|
||||||
|
<stop offset="1" stop-color="#A582E9" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="drive-far-mountain" x1="142" y1="152" x2="211" y2="216" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#E8B4EB" />
|
||||||
|
<stop offset="1" stop-color="#BB7BD7" />
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="drive-photo-clip">
|
||||||
|
<rect x="28" y="54" width="194" height="172" rx="24" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<g id="mark">
|
||||||
|
<path d="M48 48H91Q99 48 105 54L117 66Q123 72 132 72H208Q228 72 228 92V200Q228 220 208 220H48Q28 220 28 200V68Q28 48 48 48Z" fill="url(#drive-copper)" transform="translate(6 -6)" stroke="#7D4936" stroke-width=".8" stroke-linejoin="round" />
|
||||||
|
<path d="M48 48H91Q99 48 105 54L117 66Q123 72 132 72H208Q228 72 228 92V200Q228 220 208 220H48Q28 220 28 200V68Q28 48 48 48Z" fill="url(#drive-rear)" stroke="#5E3CBD" stroke-width=".8" />
|
||||||
|
<rect x="72" y="82" width="132" height="112" rx="10" fill="url(#drive-paper)" stroke="#EFE9FC" stroke-width="1" />
|
||||||
|
<rect x="51" y="97" width="140" height="109" rx="10" fill="url(#drive-paper)" stroke="#EFE9FC" stroke-width="1" />
|
||||||
|
<path d="M48 94H89Q97 94 103 100L115 112Q121 118 130 118H208Q228 118 228 138V206Q228 226 208 226H48Q28 226 28 206V114Q28 94 48 94Z" fill="url(#drive-copper)" transform="translate(6 -6)" stroke="#7D4936" stroke-width=".8" stroke-linejoin="round" />
|
||||||
|
<path d="M48 94H89Q97 94 103 100L115 112Q121 118 130 118H208Q228 118 228 138V206Q228 226 208 226H48Q28 226 28 206V114Q28 94 48 94Z" fill="url(#drive-face)" stroke="#5936B7" stroke-width=".9" />
|
||||||
|
<path d="M32 113Q32 98 48 98H89Q95 98 100 103L112 115Q120 122 130 122H208Q224 122 224 138" fill="none" stroke="#F3DDF9" stroke-opacity=".52" stroke-width="1.5" stroke-linecap="round" />
|
||||||
</g>
|
</g>
|
||||||
</g>
|
|
||||||
<text x="74" y="47">Sync</text>
|
|
||||||
</g>
|
</g>
|
||||||
<!-- photos, bottom right -->
|
<g font-family="Adwaita Sans" font-size="26" font-weight="600" fill="#FFFFFF">
|
||||||
<g transform="translate(1560 690)">
|
<g transform="translate(1000 200)">
|
||||||
<rect x="0" y="10" width="206" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
<rect x="0" y="10" width="236" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)" />
|
||||||
<rect x="0" y="0" width="206" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
<rect x="0" y="0" width="236" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5" />
|
||||||
<g transform="translate(22 20)">
|
<g transform="translate(22 20)">
|
||||||
<rect width="36" height="36" rx="10" fill="#E8618C"/>
|
<rect width="36" height="36" rx="10" fill="#6D4AFF" />
|
||||||
<rect x="8" y="9" width="20" height="18" rx="3" fill="none" stroke="#FFFFFF" stroke-width="2.4"/>
|
<path d="M8 13a2 2 0 0 1 2-2h5l2.5 2.5H26a2 2 0 0 1 2 2V25a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2z" fill="#FFFFFF" />
|
||||||
<circle cx="14" cy="15" r="2" fill="#FFFFFF"/>
|
</g>
|
||||||
<path d="M9.5 25l6-6 4 4 3-3 4 4" fill="none" stroke="#FFFFFF" stroke-width="2.4" stroke-linejoin="round"/>
|
<text x="74" y="47">On demand</text>
|
||||||
</g>
|
</g>
|
||||||
<text x="74" y="47">Photos</text>
|
<g transform="translate(1590 290)">
|
||||||
|
<rect x="0" y="10" width="164" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)" />
|
||||||
|
<rect x="0" y="0" width="164" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5" />
|
||||||
|
<g transform="translate(22 20)">
|
||||||
|
<rect width="36" height="36" rx="10" fill="#1EA885" />
|
||||||
|
<g fill="none" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M26 15a8.5 8.5 0 0 0-15-2" />
|
||||||
|
<path d="M10 9v4.5h4.5" />
|
||||||
|
<path d="M10 21a8.5 8.5 0 0 0 15 2" />
|
||||||
|
<path d="M26 27v-4.5h-4.5" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text x="74" y="47">Sync</text>
|
||||||
|
</g>
|
||||||
|
<g transform="translate(1560 690)">
|
||||||
|
<rect x="0" y="10" width="206" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)" />
|
||||||
|
<rect x="0" y="0" width="206" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5" />
|
||||||
|
<g transform="translate(22 20)">
|
||||||
|
<rect width="36" height="36" rx="10" fill="#E8618C" />
|
||||||
|
<rect x="8" y="9" width="20" height="18" rx="3" fill="none" stroke="#FFFFFF" stroke-width="2.4" />
|
||||||
|
<circle cx="14" cy="15" r="2" fill="#FFFFFF" />
|
||||||
|
<path d="M9.5 25l6-6 4 4 3-3 4 4" fill="none" stroke="#FFFFFF" stroke-width="2.4" stroke-linejoin="round" />
|
||||||
|
</g>
|
||||||
|
<text x="74" y="47">Photos</text>
|
||||||
|
</g>
|
||||||
|
<g transform="translate(980 790)">
|
||||||
|
<rect x="0" y="10" width="206" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)" />
|
||||||
|
<rect x="0" y="0" width="206" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5" />
|
||||||
|
<g transform="translate(22 20)">
|
||||||
|
<rect width="36" height="36" rx="10" fill="#3B3F5C" />
|
||||||
|
<path d="M9 12l6 6-6 6" fill="none" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
<path d="M18 25h9" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round" />
|
||||||
|
</g>
|
||||||
|
<text x="74" y="48" font-family="JetBrainsMono NF" font-size="25" font-weight="700">pdfs</text>
|
||||||
|
<text x="150" y="48" font-weight="500" fill="#B9B0D9">CLI</text>
|
||||||
|
</g>
|
||||||
</g>
|
</g>
|
||||||
<!-- terminal, bottom left -->
|
<g font-family="Adwaita Sans">
|
||||||
<g transform="translate(980 790)">
|
<g transform="translate(140 292)">
|
||||||
<rect x="0" y="10" width="206" height="76" rx="22" fill="#000000" opacity="0.35" filter="url(#chipshadow)"/>
|
<rect width="410" height="48" rx="24" fill="#6D4AFF" fill-opacity="0.18" stroke="#8A6CFF" stroke-opacity="0.6" stroke-width="1.5" />
|
||||||
<rect x="0" y="0" width="206" height="76" rx="22" fill="#2A2058" fill-opacity="0.85" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1.5"/>
|
<circle cx="28" cy="24" r="6" fill="#A48BFF" />
|
||||||
<g transform="translate(22 20)">
|
<text x="46" y="32" font-size="21" font-weight="700" letter-spacing="2.4" fill="#D6CCFF">UNOFFICIAL · OPEN SOURCE</text>
|
||||||
<rect width="36" height="36" rx="10" fill="#3B3F5C"/>
|
</g>
|
||||||
<path d="M9 12l6 6-6 6" fill="none" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
|
<text x="134" y="478" font-size="124" font-weight="800" letter-spacing="-3" fill="#FFFFFF">Proton Drive</text>
|
||||||
<path d="M18 25h9" stroke="#FFFFFF" stroke-width="2.6" stroke-linecap="round"/>
|
<text x="134" y="610" font-size="124" font-weight="800" letter-spacing="-3" fill="url(#title2)">for Linux</text>
|
||||||
</g>
|
<text x="140" y="702" font-size="38" font-weight="400" fill="#B9B0D9">Your Drive as a folder, and a native GTK4 app.</text>
|
||||||
<text x="74" y="48" font-family="JetBrainsMono NF" font-size="25" font-weight="700">pdfs</text>
|
<text x="140" y="752" font-size="38" font-weight="400" fill="#B9B0D9">No Electron.</text>
|
||||||
<text x="150" y="48" font-weight="500" fill="#B9B0D9">CLI</text>
|
|
||||||
</g>
|
</g>
|
||||||
</g>
|
<g font-family="JetBrainsMono NF" font-size="24" fill="#8C83B0">
|
||||||
|
<text x="140" y="968">github.com/narrrl/proton-drive-linux</text>
|
||||||
<!-- text block -->
|
</g>
|
||||||
<g font-family="Adwaita Sans">
|
<g font-family="Adwaita Sans" font-size="22" fill="#6F6894">
|
||||||
<g transform="translate(140 292)">
|
<text x="1780" y="968" text-anchor="end">Not affiliated with Proton AG</text>
|
||||||
<rect width="410" height="48" rx="24" fill="#6D4AFF" fill-opacity="0.18" stroke="#8A6CFF" stroke-opacity="0.6" stroke-width="1.5"/>
|
|
||||||
<circle cx="28" cy="24" r="6" fill="#A48BFF"/>
|
|
||||||
<text x="46" y="32" font-size="21" font-weight="700" letter-spacing="2.4" fill="#D6CCFF">UNOFFICIAL · OPEN SOURCE</text>
|
|
||||||
</g>
|
</g>
|
||||||
<text x="134" y="478" font-size="124" font-weight="800" letter-spacing="-3" fill="#FFFFFF">Proton Drive</text>
|
|
||||||
<text x="134" y="610" font-size="124" font-weight="800" letter-spacing="-3" fill="url(#title2)">for Linux</text>
|
|
||||||
<text x="140" y="702" font-size="38" font-weight="400" fill="#B9B0D9">Your Drive as a folder, and a native GTK4 app.</text>
|
|
||||||
<text x="140" y="752" font-size="38" font-weight="400" fill="#B9B0D9">No Electron.</text>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- footer -->
|
|
||||||
<g font-family="JetBrainsMono NF" font-size="24" fill="#8C83B0">
|
|
||||||
<text x="140" y="968">github.com/narrrl/proton-drive-linux</text>
|
|
||||||
</g>
|
|
||||||
<g font-family="Adwaita Sans" font-size="22" fill="#6F6894">
|
|
||||||
<text x="1780" y="968" text-anchor="end">Not affiliated with Proton AG</text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 33 KiB |
@@ -1,36 +1,44 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" data-app="drive" role="img" aria-labelledby="drive-title drive-desc">
|
||||||
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Proton Drive for Linux">
|
<title id="drive-title">Proton Drive for Linux</title>
|
||||||
<defs>
|
<desc id="drive-desc">Frontal violet and pink vector icon with shallow metallic copper backing.</desc>
|
||||||
<linearGradient id="pdl-face" x1="12" y1="12" x2="116" y2="112" gradientUnits="userSpaceOnUse">
|
<defs>
|
||||||
<stop offset="0" stop-color="#A48BFF"/>
|
<linearGradient id="drive-face" x1="36" y1="212" x2="220" y2="54" gradientUnits="userSpaceOnUse">
|
||||||
<stop offset="0.55" stop-color="#7552FF"/>
|
<stop stop-color="#6240DA"/><stop offset=".52" stop-color="#8056EF"/><stop offset="1" stop-color="#D58BDF"/>
|
||||||
<stop offset="1" stop-color="#5B36F2"/>
|
</linearGradient>
|
||||||
</linearGradient>
|
<linearGradient id="drive-rear" x1="26" y1="42" x2="218" y2="220" gradientUnits="userSpaceOnUse">
|
||||||
<linearGradient id="pdl-cloud" x1="0" y1="34" x2="0" y2="88" gradientUnits="userSpaceOnUse">
|
<stop stop-color="#8C68EE"/><stop offset="1" stop-color="#5533B5"/>
|
||||||
<stop offset="0" stop-color="#FFFFFF"/>
|
</linearGradient>
|
||||||
<stop offset="1" stop-color="#ECE6FF"/>
|
<linearGradient id="drive-paper" x1="60" y1="80" x2="180" y2="162" gradientUnits="userSpaceOnUse">
|
||||||
</linearGradient>
|
<stop stop-color="#E7DFFA"/><stop offset="1" stop-color="#BDA5EF"/>
|
||||||
<!-- the cloud, with the arrow cut out of it as negative space -->
|
</linearGradient>
|
||||||
<mask id="pdl-cut" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
<linearGradient id="drive-copper" x1="32" y1="32" x2="232" y2="224" gradientUnits="userSpaceOnUse">
|
||||||
<g fill="#FFFFFF">
|
<stop stop-color="#703E30"/><stop offset=".16" stop-color="#B47456"/>
|
||||||
<circle cx="66" cy="57" r="23"/>
|
<stop offset=".28" stop-color="#E6B296"/><stop offset=".32" stop-color="#F8D8C3"/>
|
||||||
<circle cx="42" cy="68" r="16"/>
|
<stop offset=".37" stop-color="#BB7C5A"/><stop offset=".56" stop-color="#8A4D36"/>
|
||||||
<circle cx="88" cy="69" r="15"/>
|
<stop offset=".69" stop-color="#D69B77"/><stop offset=".75" stop-color="#F2C9AA"/>
|
||||||
<rect x="26" y="68" width="77" height="20" rx="10"/>
|
<stop offset=".81" stop-color="#B87956"/><stop offset="1" stop-color="#713F30"/>
|
||||||
</g>
|
</linearGradient>
|
||||||
<g stroke="#000000" stroke-width="7.5" stroke-linecap="round" stroke-linejoin="round">
|
<linearGradient id="drive-sun" x1="172" y1="82" x2="201" y2="112" gradientUnits="userSpaceOnUse">
|
||||||
<path d="M64 49v26"/>
|
<stop stop-color="#8D513A"/><stop offset=".33" stop-color="#DDA581"/>
|
||||||
<path d="M54.5 65.5l9.5 9.5 9.5-9.5"/>
|
<stop offset=".47" stop-color="#F7D8B8"/><stop offset=".53" stop-color="#D69B74"/>
|
||||||
</g>
|
<stop offset="1" stop-color="#925439"/>
|
||||||
</mask>
|
</linearGradient>
|
||||||
</defs>
|
<linearGradient id="drive-mountain" x1="44" y1="148" x2="186" y2="218" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#D9C9FA"/><stop offset="1" stop-color="#A582E9"/>
|
||||||
<!-- base: a rounded tile with a darker lower edge for depth -->
|
</linearGradient>
|
||||||
<rect x="12" y="16" width="104" height="100" rx="26" fill="#4424C0"/>
|
<linearGradient id="drive-far-mountain" x1="142" y1="152" x2="211" y2="216" gradientUnits="userSpaceOnUse">
|
||||||
<rect x="12" y="12" width="104" height="100" rx="26" fill="url(#pdl-face)"/>
|
<stop stop-color="#E8B4EB"/><stop offset="1" stop-color="#BB7BD7"/>
|
||||||
<rect x="12.5" y="12.5" width="103" height="99" rx="25.5" stroke="#FFFFFF" stroke-opacity="0.2"/>
|
</linearGradient>
|
||||||
|
<clipPath id="drive-photo-clip"><rect x="28" y="54" width="194" height="172" rx="24"/></clipPath>
|
||||||
<!-- cloud shadow, then the cloud itself -->
|
</defs>
|
||||||
<rect y="3" width="128" height="128" fill="#2E1596" fill-opacity="0.3" mask="url(#pdl-cut)"/>
|
<!-- Canonical vector artwork; regenerate platform assets with scripts/render-branding.py. -->
|
||||||
<rect width="128" height="128" fill="url(#pdl-cloud)" mask="url(#pdl-cut)"/>
|
<g id="mark">
|
||||||
|
<path d="M48 48H91Q99 48 105 54L117 66Q123 72 132 72H208Q228 72 228 92V200Q228 220 208 220H48Q28 220 28 200V68Q28 48 48 48Z" fill="url(#drive-copper)" transform="translate(6 -6)" stroke="#7D4936" stroke-width=".8" stroke-linejoin="round"/>
|
||||||
|
<path d="M48 48H91Q99 48 105 54L117 66Q123 72 132 72H208Q228 72 228 92V200Q228 220 208 220H48Q28 220 28 200V68Q28 48 48 48Z" fill="url(#drive-rear)" stroke="#5E3CBD" stroke-width=".8"/>
|
||||||
|
<rect x="72" y="82" width="132" height="112" rx="10" fill="url(#drive-paper)" stroke="#EFE9FC" stroke-width="1"/>
|
||||||
|
<rect x="51" y="97" width="140" height="109" rx="10" fill="url(#drive-paper)" stroke="#EFE9FC" stroke-width="1"/>
|
||||||
|
<path d="M48 94H89Q97 94 103 100L115 112Q121 118 130 118H208Q228 118 228 138V206Q228 226 208 226H48Q28 226 28 206V114Q28 94 48 94Z" fill="url(#drive-copper)" transform="translate(6 -6)" stroke="#7D4936" stroke-width=".8" stroke-linejoin="round"/>
|
||||||
|
<path d="M48 94H89Q97 94 103 100L115 112Q121 118 130 118H208Q228 118 228 138V206Q228 226 208 226H48Q28 226 28 206V114Q28 94 48 94Z" fill="url(#drive-face)" stroke="#5936B7" stroke-width=".9"/>
|
||||||
|
<path d="M32 113Q32 98 48 98H89Q95 98 100 103L112 115Q120 122 130 122H208Q224 122 224 138" fill="none" stroke="#F3DDF9" stroke-opacity=".52" stroke-width="1.5" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 283 KiB After Width: | Height: | Size: 283 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 97 KiB |
@@ -9,7 +9,7 @@
|
|||||||
# Build + install: cd packaging && makepkg -fi
|
# Build + install: cd packaging && makepkg -fi
|
||||||
|
|
||||||
pkgname=proton-drive-linux
|
pkgname=proton-drive-linux
|
||||||
pkgver=3.8.0
|
pkgver=3.8.1
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Unofficial Proton Drive client for Linux: files-on-demand FUSE mount, CLI, GTK4 app + tray"
|
pkgdesc="Unofficial Proton Drive client for Linux: files-on-demand FUSE mount, CLI, GTK4 app + tray"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pkgbase = proton-drive-for-linux-bin
|
pkgbase = proton-drive-for-linux-bin
|
||||||
pkgdesc = Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (binaries)
|
pkgdesc = Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (binaries)
|
||||||
pkgver = 3.7.0
|
pkgver = 3.8.0
|
||||||
pkgrel = 1
|
pkgrel = 1
|
||||||
url = https://proton-drive.narl.io
|
url = https://proton-drive.narl.io
|
||||||
install = proton-drive.install
|
install = proton-drive.install
|
||||||
@@ -22,15 +22,15 @@ pkgbase = proton-drive-for-linux-bin
|
|||||||
optdepends = xdg-utils: "Open folder" action in the tray menu
|
optdepends = xdg-utils: "Open folder" action in the tray menu
|
||||||
optdepends = fzf: search-as-you-type launcher (pdfs-prompt --fzf)
|
optdepends = fzf: search-as-you-type launcher (pdfs-prompt --fzf)
|
||||||
optdepends = foot: terminal that hosts pdfs-prompt --fzf when started from a keybinding
|
optdepends = foot: terminal that hosts pdfs-prompt --fzf when started from a keybinding
|
||||||
provides = proton-drive-for-linux=3.7.0
|
provides = proton-drive-for-linux=3.8.0
|
||||||
provides = proton-drive-linux=3.7.0
|
provides = proton-drive-linux=3.8.0
|
||||||
provides = pdfs
|
provides = pdfs
|
||||||
conflicts = proton-drive-linux
|
conflicts = proton-drive-linux
|
||||||
conflicts = proton-drive-for-linux
|
conflicts = proton-drive-for-linux
|
||||||
conflicts = proton-drive-for-linux-git
|
conflicts = proton-drive-for-linux-git
|
||||||
options = !strip
|
options = !strip
|
||||||
options = !debug
|
options = !debug
|
||||||
source = proton-drive-linux-3.7.0-x86_64.tar.gz::https://github.com/narrrl/proton-drive-linux/releases/download/v3.7.0/proton-drive-linux-3.7.0-x86_64.tar.gz
|
source = proton-drive-linux-3.8.0-x86_64.tar.gz::https://github.com/narrrl/proton-drive-linux/releases/download/v3.8.0/proton-drive-linux-3.8.0-x86_64.tar.gz
|
||||||
sha256sums = SKIP
|
sha256sums = 99348fbf9121624701ae43e52776e5d1c469ff5cd5e52cd216bf8cb969e0bab2
|
||||||
|
|
||||||
pkgname = proton-drive-for-linux-bin
|
pkgname = proton-drive-for-linux-bin
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Nils Pukropp <contact@narl.io>
|
# Maintainer: Nils Pukropp <contact@narl.io>
|
||||||
|
|
||||||
pkgname=proton-drive-for-linux-bin
|
pkgname=proton-drive-for-linux-bin
|
||||||
pkgver=3.7.0
|
pkgver=3.8.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (binaries)"
|
pkgdesc="Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (binaries)"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
@@ -29,7 +29,7 @@ _tag="v$pkgver"
|
|||||||
# (desktop files, icon, user service, translations, completions) in a /usr-like
|
# (desktop files, icon, user service, translations, completions) in a /usr-like
|
||||||
# tree under one directory.
|
# tree under one directory.
|
||||||
source=("proton-drive-linux-$pkgver-x86_64.tar.gz::$_repo/releases/download/$_tag/proton-drive-linux-$pkgver-x86_64.tar.gz")
|
source=("proton-drive-linux-$pkgver-x86_64.tar.gz::$_repo/releases/download/$_tag/proton-drive-linux-$pkgver-x86_64.tar.gz")
|
||||||
sha256sums=('SKIP')
|
sha256sums=('99348fbf9121624701ae43e52776e5d1c469ff5cd5e52cd216bf8cb969e0bab2')
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd "$srcdir/proton-drive-linux-$pkgver-x86_64"
|
cd "$srcdir/proton-drive-linux-$pkgver-x86_64"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pkgbase = proton-drive-for-linux-git
|
pkgbase = proton-drive-for-linux-git
|
||||||
pkgdesc = Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (git)
|
pkgdesc = Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (git)
|
||||||
pkgver = 3.7.0.r0.g7ab14bb
|
pkgver = 3.8.0.r0.g6fa91e8
|
||||||
pkgrel = 1
|
pkgrel = 1
|
||||||
url = https://proton-drive.narl.io
|
url = https://proton-drive.narl.io
|
||||||
install = proton-drive.install
|
install = proton-drive.install
|
||||||
@@ -25,8 +25,8 @@ pkgbase = proton-drive-for-linux-git
|
|||||||
optdepends = xdg-utils: "Open folder" action in the tray menu
|
optdepends = xdg-utils: "Open folder" action in the tray menu
|
||||||
optdepends = fzf: search-as-you-type launcher (pdfs-prompt --fzf)
|
optdepends = fzf: search-as-you-type launcher (pdfs-prompt --fzf)
|
||||||
optdepends = foot: terminal that hosts pdfs-prompt --fzf when started from a keybinding
|
optdepends = foot: terminal that hosts pdfs-prompt --fzf when started from a keybinding
|
||||||
provides = proton-drive-for-linux=3.7.0.r0.g7ab14bb
|
provides = proton-drive-for-linux=3.8.0.r0.g6fa91e8
|
||||||
provides = proton-drive-linux=3.7.0.r0.g7ab14bb
|
provides = proton-drive-linux=3.8.0.r0.g6fa91e8
|
||||||
provides = pdfs
|
provides = pdfs
|
||||||
conflicts = proton-drive-linux
|
conflicts = proton-drive-linux
|
||||||
conflicts = proton-drive-for-linux
|
conflicts = proton-drive-for-linux
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Nils Pukropp <contact@narl.io>
|
# Maintainer: Nils Pukropp <contact@narl.io>
|
||||||
|
|
||||||
pkgname=proton-drive-for-linux-git
|
pkgname=proton-drive-for-linux-git
|
||||||
pkgver=3.7.0.r0.g7ab14bb
|
pkgver=3.8.0.r0.g6fa91e8
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (git)"
|
pkgdesc="Unofficial Proton Drive client: FUSE files-on-demand mount, CLI, GTK4 app, tray (git)"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pkgbase = proton-drive-for-linux
|
pkgbase = proton-drive-for-linux
|
||||||
pkgdesc = Unofficial Proton Drive client: files-on-demand FUSE mount, CLI, GTK4 app and tray
|
pkgdesc = Unofficial Proton Drive client: files-on-demand FUSE mount, CLI, GTK4 app and tray
|
||||||
pkgver = 3.7.0
|
pkgver = 3.8.0
|
||||||
pkgrel = 1
|
pkgrel = 1
|
||||||
url = https://proton-drive.narl.io
|
url = https://proton-drive.narl.io
|
||||||
install = proton-drive.install
|
install = proton-drive.install
|
||||||
@@ -24,13 +24,13 @@ pkgbase = proton-drive-for-linux
|
|||||||
optdepends = xdg-utils: "Open folder" action in the tray menu
|
optdepends = xdg-utils: "Open folder" action in the tray menu
|
||||||
optdepends = fzf: search-as-you-type launcher (pdfs-prompt --fzf)
|
optdepends = fzf: search-as-you-type launcher (pdfs-prompt --fzf)
|
||||||
optdepends = foot: terminal that hosts pdfs-prompt --fzf when started from a keybinding
|
optdepends = foot: terminal that hosts pdfs-prompt --fzf when started from a keybinding
|
||||||
provides = proton-drive-linux=3.7.0
|
provides = proton-drive-linux=3.8.0
|
||||||
provides = pdfs
|
provides = pdfs
|
||||||
conflicts = proton-drive-linux
|
conflicts = proton-drive-linux
|
||||||
conflicts = proton-drive-for-linux-bin
|
conflicts = proton-drive-for-linux-bin
|
||||||
conflicts = proton-drive-for-linux-git
|
conflicts = proton-drive-for-linux-git
|
||||||
options = !lto
|
options = !lto
|
||||||
source = proton-drive-for-linux-3.7.0.tar.gz::https://github.com/narrrl/proton-drive-linux/archive/refs/tags/v3.7.0.tar.gz
|
source = proton-drive-for-linux-3.8.0.tar.gz::https://github.com/narrrl/proton-drive-linux/archive/refs/tags/v3.8.0.tar.gz
|
||||||
sha256sums = 542c534976e335cde6658de127e1eefffade9057d5332fd33457bc371c7a2737
|
sha256sums = 095186fa108f27ff2b175188bb13466a94cc8ecfd71088df47a41d4d9baa58c1
|
||||||
|
|
||||||
pkgname = proton-drive-for-linux
|
pkgname = proton-drive-for-linux
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Nils Pukropp <contact@narl.io>
|
# Maintainer: Nils Pukropp <contact@narl.io>
|
||||||
|
|
||||||
pkgname=proton-drive-for-linux
|
pkgname=proton-drive-for-linux
|
||||||
pkgver=3.7.0
|
pkgver=3.8.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Unofficial Proton Drive client: files-on-demand FUSE mount, CLI, GTK4 app and tray"
|
pkgdesc="Unofficial Proton Drive client: files-on-demand FUSE mount, CLI, GTK4 app and tray"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
@@ -26,7 +26,7 @@ options=('!lto')
|
|||||||
# Stops the running daemon before removal, so the mount stops mirroring deletes.
|
# Stops the running daemon before removal, so the mount stops mirroring deletes.
|
||||||
install=proton-drive.install
|
install=proton-drive.install
|
||||||
source=("$pkgname-$pkgver.tar.gz::$_repo/archive/refs/tags/v$pkgver.tar.gz")
|
source=("$pkgname-$pkgver.tar.gz::$_repo/archive/refs/tags/v$pkgver.tar.gz")
|
||||||
sha256sums=('542c534976e335cde6658de127e1eefffade9057d5332fd33457bc371c7a2737')
|
sha256sums=('095186fa108f27ff2b175188bb13466a94cc8ecfd71088df47a41d4d9baa58c1')
|
||||||
|
|
||||||
_srcname="proton-drive-linux-$pkgver"
|
_srcname="proton-drive-linux-$pkgver"
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ release assets:
|
|||||||
| Source | What it is |
|
| Source | What it is |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `Source0` | GitHub's archive of the `v<version>` tag |
|
| `Source0` | GitHub's archive of the `v<version>` tag |
|
||||||
| `Source1` | `proton-drive-linux-vendor-<version>.tar.xz`: every crate from `Cargo.lock`, made by `cargo vendor` in `release.yml` |
|
| `Source1` | `proton-drive-linux-vendor-<version>.tar.xz`: the crates and source mappings generated by `cargo vendor` in `release.yml` |
|
||||||
|
|
||||||
With the vendored crates the build needs no network, so the COPR project keeps network access
|
With the vendored crates the build needs no network, so the COPR project keeps network access
|
||||||
off.
|
off.
|
||||||
|
|||||||
@@ -1,36 +1,44 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" data-app="drive" role="img" aria-labelledby="drive-title drive-desc">
|
||||||
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Proton Drive for Linux">
|
<title id="drive-title">Proton Drive for Linux</title>
|
||||||
<defs>
|
<desc id="drive-desc">Frontal violet and pink vector icon with shallow metallic copper backing.</desc>
|
||||||
<linearGradient id="pdl-face" x1="12" y1="12" x2="116" y2="112" gradientUnits="userSpaceOnUse">
|
<defs>
|
||||||
<stop offset="0" stop-color="#A48BFF"/>
|
<linearGradient id="drive-face" x1="36" y1="212" x2="220" y2="54" gradientUnits="userSpaceOnUse">
|
||||||
<stop offset="0.55" stop-color="#7552FF"/>
|
<stop stop-color="#6240DA"/><stop offset=".52" stop-color="#8056EF"/><stop offset="1" stop-color="#D58BDF"/>
|
||||||
<stop offset="1" stop-color="#5B36F2"/>
|
</linearGradient>
|
||||||
</linearGradient>
|
<linearGradient id="drive-rear" x1="26" y1="42" x2="218" y2="220" gradientUnits="userSpaceOnUse">
|
||||||
<linearGradient id="pdl-cloud" x1="0" y1="34" x2="0" y2="88" gradientUnits="userSpaceOnUse">
|
<stop stop-color="#8C68EE"/><stop offset="1" stop-color="#5533B5"/>
|
||||||
<stop offset="0" stop-color="#FFFFFF"/>
|
</linearGradient>
|
||||||
<stop offset="1" stop-color="#ECE6FF"/>
|
<linearGradient id="drive-paper" x1="60" y1="80" x2="180" y2="162" gradientUnits="userSpaceOnUse">
|
||||||
</linearGradient>
|
<stop stop-color="#E7DFFA"/><stop offset="1" stop-color="#BDA5EF"/>
|
||||||
<!-- the cloud, with the arrow cut out of it as negative space -->
|
</linearGradient>
|
||||||
<mask id="pdl-cut" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
<linearGradient id="drive-copper" x1="32" y1="32" x2="232" y2="224" gradientUnits="userSpaceOnUse">
|
||||||
<g fill="#FFFFFF">
|
<stop stop-color="#703E30"/><stop offset=".16" stop-color="#B47456"/>
|
||||||
<circle cx="66" cy="57" r="23"/>
|
<stop offset=".28" stop-color="#E6B296"/><stop offset=".32" stop-color="#F8D8C3"/>
|
||||||
<circle cx="42" cy="68" r="16"/>
|
<stop offset=".37" stop-color="#BB7C5A"/><stop offset=".56" stop-color="#8A4D36"/>
|
||||||
<circle cx="88" cy="69" r="15"/>
|
<stop offset=".69" stop-color="#D69B77"/><stop offset=".75" stop-color="#F2C9AA"/>
|
||||||
<rect x="26" y="68" width="77" height="20" rx="10"/>
|
<stop offset=".81" stop-color="#B87956"/><stop offset="1" stop-color="#713F30"/>
|
||||||
</g>
|
</linearGradient>
|
||||||
<g stroke="#000000" stroke-width="7.5" stroke-linecap="round" stroke-linejoin="round">
|
<linearGradient id="drive-sun" x1="172" y1="82" x2="201" y2="112" gradientUnits="userSpaceOnUse">
|
||||||
<path d="M64 49v26"/>
|
<stop stop-color="#8D513A"/><stop offset=".33" stop-color="#DDA581"/>
|
||||||
<path d="M54.5 65.5l9.5 9.5 9.5-9.5"/>
|
<stop offset=".47" stop-color="#F7D8B8"/><stop offset=".53" stop-color="#D69B74"/>
|
||||||
</g>
|
<stop offset="1" stop-color="#925439"/>
|
||||||
</mask>
|
</linearGradient>
|
||||||
</defs>
|
<linearGradient id="drive-mountain" x1="44" y1="148" x2="186" y2="218" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#D9C9FA"/><stop offset="1" stop-color="#A582E9"/>
|
||||||
<!-- base: a rounded tile with a darker lower edge for depth -->
|
</linearGradient>
|
||||||
<rect x="12" y="16" width="104" height="100" rx="26" fill="#4424C0"/>
|
<linearGradient id="drive-far-mountain" x1="142" y1="152" x2="211" y2="216" gradientUnits="userSpaceOnUse">
|
||||||
<rect x="12" y="12" width="104" height="100" rx="26" fill="url(#pdl-face)"/>
|
<stop stop-color="#E8B4EB"/><stop offset="1" stop-color="#BB7BD7"/>
|
||||||
<rect x="12.5" y="12.5" width="103" height="99" rx="25.5" stroke="#FFFFFF" stroke-opacity="0.2"/>
|
</linearGradient>
|
||||||
|
<clipPath id="drive-photo-clip"><rect x="28" y="54" width="194" height="172" rx="24"/></clipPath>
|
||||||
<!-- cloud shadow, then the cloud itself -->
|
</defs>
|
||||||
<rect y="3" width="128" height="128" fill="#2E1596" fill-opacity="0.3" mask="url(#pdl-cut)"/>
|
<!-- Canonical vector artwork; regenerate platform assets with scripts/render-branding.py. -->
|
||||||
<rect width="128" height="128" fill="url(#pdl-cloud)" mask="url(#pdl-cut)"/>
|
<g id="mark">
|
||||||
|
<path d="M48 48H91Q99 48 105 54L117 66Q123 72 132 72H208Q228 72 228 92V200Q228 220 208 220H48Q28 220 28 200V68Q28 48 48 48Z" fill="url(#drive-copper)" transform="translate(6 -6)" stroke="#7D4936" stroke-width=".8" stroke-linejoin="round"/>
|
||||||
|
<path d="M48 48H91Q99 48 105 54L117 66Q123 72 132 72H208Q228 72 228 92V200Q228 220 208 220H48Q28 220 28 200V68Q28 48 48 48Z" fill="url(#drive-rear)" stroke="#5E3CBD" stroke-width=".8"/>
|
||||||
|
<rect x="72" y="82" width="132" height="112" rx="10" fill="url(#drive-paper)" stroke="#EFE9FC" stroke-width="1"/>
|
||||||
|
<rect x="51" y="97" width="140" height="109" rx="10" fill="url(#drive-paper)" stroke="#EFE9FC" stroke-width="1"/>
|
||||||
|
<path d="M48 94H89Q97 94 103 100L115 112Q121 118 130 118H208Q228 118 228 138V206Q228 226 208 226H48Q28 226 28 206V114Q28 94 48 94Z" fill="url(#drive-copper)" transform="translate(6 -6)" stroke="#7D4936" stroke-width=".8" stroke-linejoin="round"/>
|
||||||
|
<path d="M48 94H89Q97 94 103 100L115 112Q121 118 130 118H208Q228 118 228 138V206Q228 226 208 226H48Q28 226 28 206V114Q28 94 48 94Z" fill="url(#drive-face)" stroke="#5936B7" stroke-width=".9"/>
|
||||||
|
<path d="M32 113Q32 98 48 98H89Q95 98 100 103L112 115Q120 122 130 122H208Q224 122 224 138" fill="none" stroke="#F3DDF9" stroke-opacity=".52" stroke-width="1.5" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 3.6 KiB |
@@ -44,7 +44,10 @@ rustPlatform.buildRustPackage {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoLock.lockFile = ../../Cargo.lock;
|
cargoLock = {
|
||||||
|
lockFile = ../../Cargo.lock;
|
||||||
|
allowBuiltinFetchGit = true;
|
||||||
|
};
|
||||||
|
|
||||||
cargoBuildFlags = [
|
cargoBuildFlags = [
|
||||||
"--bin"
|
"--bin"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# - From a checkout (local builds and the release workflow). From the repository root:
|
# - From a checkout (local builds and the release workflow). From the repository root:
|
||||||
# rpmbuild -bb packaging/proton-drive-linux.spec --define "git_dir $PWD" ...
|
# rpmbuild -bb packaging/proton-drive-linux.spec --define "git_dir $PWD" ...
|
||||||
# %build needs network so cargo can fetch crates.io (same trade-off as the Arch PKGBUILD).
|
# %build needs network so Cargo can fetch crates.io and Git dependencies.
|
||||||
# - From the release tarballs (COPR, .github/workflows/copr.yml), when git_dir is not
|
# - From the release tarballs (COPR, .github/workflows/copr.yml), when git_dir is not
|
||||||
# defined. Source1 holds every crate, so the build runs offline.
|
# defined. Source1 holds every crate, so the build runs offline.
|
||||||
|
|
||||||
@@ -72,16 +72,19 @@ system tray and search launcher. Unofficial and not affiliated with Proton AG.
|
|||||||
test -f %{git_dir}/Cargo.toml
|
test -f %{git_dir}/Cargo.toml
|
||||||
cp -a %{git_dir}/LICENSE .
|
cp -a %{git_dir}/LICENSE .
|
||||||
%else
|
%else
|
||||||
# -a 1 unpacks the vendored crates into vendor/ inside the source tree.
|
# -a 1 unpacks the vendored crates and their source mappings.
|
||||||
%autosetup -n %{name}-%{version} -a 1
|
%autosetup -n %{name}-%{version} -a 1
|
||||||
mkdir -p .cargo
|
# Older vendor tarballs contained only crates.io dependencies.
|
||||||
cat > .cargo/config.toml <<'EOF'
|
if [ ! -f .cargo/config.toml ]; then
|
||||||
|
mkdir -p .cargo
|
||||||
|
cat > .cargo/config.toml <<'EOF'
|
||||||
[source.crates-io]
|
[source.crates-io]
|
||||||
replace-with = "vendored-sources"
|
replace-with = "vendored-sources"
|
||||||
|
|
||||||
[source.vendored-sources]
|
[source.vendored-sources]
|
||||||
directory = "vendor"
|
directory = "vendor"
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ crates/pdfs-gui/src/app/pages/activity_text.rs
|
|||||||
crates/pdfs-gui/src/app/pages/albums.rs
|
crates/pdfs-gui/src/app/pages/albums.rs
|
||||||
crates/pdfs-gui/src/app/pages/browser.rs
|
crates/pdfs-gui/src/app/pages/browser.rs
|
||||||
crates/pdfs-gui/src/app/pages/devices.rs
|
crates/pdfs-gui/src/app/pages/devices.rs
|
||||||
|
crates/pdfs-gui/src/app/pages/drive_galleries.rs
|
||||||
crates/pdfs-gui/src/app/pages/duplicates.rs
|
crates/pdfs-gui/src/app/pages/duplicates.rs
|
||||||
crates/pdfs-gui/src/app/pages/locations.rs
|
crates/pdfs-gui/src/app/pages/locations.rs
|
||||||
crates/pdfs-gui/src/app/pages/login.rs
|
crates/pdfs-gui/src/app/pages/login.rs
|
||||||
|
|||||||
@@ -0,0 +1,273 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Render the vector branding into desktop, Android, iOS and Windows assets.
|
||||||
|
|
||||||
|
Kept identical across the suite; each checkout renders independently.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
|
||||||
|
SVG = "{http://www.w3.org/2000/svg}"
|
||||||
|
ANDROID = "{http://schemas.android.com/apk/res/android}"
|
||||||
|
AAPT = "{http://schemas.android.com/aapt}"
|
||||||
|
ET.register_namespace("", SVG[1:-1])
|
||||||
|
ET.register_namespace("android", ANDROID[1:-1])
|
||||||
|
ET.register_namespace("aapt", AAPT[1:-1])
|
||||||
|
HEADER = '<?xml version="1.0" encoding="utf-8"?>\n'
|
||||||
|
GENERATED = '<!-- Generated by scripts/render-branding.py; edit images/logo.svg. -->\n'
|
||||||
|
ROOT = Path(__file__).resolve().parent.parent
|
||||||
|
BACKGROUND = "#F4F0FA"
|
||||||
|
|
||||||
|
|
||||||
|
def run(*args, data=None):
|
||||||
|
return subprocess.run(args, input=data, stdout=subprocess.PIPE, check=True).stdout
|
||||||
|
|
||||||
|
|
||||||
|
def render(svg, size, *, opaque=False):
|
||||||
|
png = run("rsvg-convert", "-w", str(size), data=svg.encode())
|
||||||
|
options = ["-background", BACKGROUND, "-alpha", "remove", "-alpha", "off"] if opaque else []
|
||||||
|
return run("magick", "-", *options, "-strip", "PNG:-", data=png)
|
||||||
|
|
||||||
|
|
||||||
|
def shape_path(node):
|
||||||
|
"""Use the same paths on Android, including rounded rectangles and circles."""
|
||||||
|
tag = node.tag.removeprefix(SVG)
|
||||||
|
a = node.attrib
|
||||||
|
if tag == "path":
|
||||||
|
return a["d"]
|
||||||
|
if tag == "circle":
|
||||||
|
x, y, r = (float(a[k]) for k in ("cx", "cy", "r"))
|
||||||
|
return f"M{x-r:g} {y:g}a{r:g} {r:g} 0 1 0 {2*r:g} 0a{r:g} {r:g} 0 1 0 {-2*r:g} 0Z"
|
||||||
|
if tag == "rect":
|
||||||
|
x, y = float(a.get("x", 0)), float(a.get("y", 0))
|
||||||
|
w, h = float(a["width"]), float(a["height"])
|
||||||
|
rx = min(float(a.get("rx", a.get("ry", 0))), w / 2)
|
||||||
|
ry = min(float(a.get("ry", a.get("rx", 0))), h / 2)
|
||||||
|
if not rx or not ry:
|
||||||
|
return f"M{x:g} {y:g}h{w:g}v{h:g}h{-w:g}Z"
|
||||||
|
return (f"M{x+rx:g} {y:g}H{x+w-rx:g}a{rx:g} {ry:g} 0 0 1 {rx:g} {ry:g}"
|
||||||
|
f"V{y+h-ry:g}a{rx:g} {ry:g} 0 0 1 {-rx:g} {ry:g}"
|
||||||
|
f"H{x+rx:g}a{rx:g} {ry:g} 0 0 1 {-rx:g} {-ry:g}"
|
||||||
|
f"V{y+ry:g}a{rx:g} {ry:g} 0 0 1 {rx:g} {-ry:g}Z")
|
||||||
|
raise ValueError(f"Unsupported SVG shape: {tag}")
|
||||||
|
|
||||||
|
|
||||||
|
def color(value):
|
||||||
|
if value == "none":
|
||||||
|
return "#00000000"
|
||||||
|
if re.fullmatch(r"#[0-9a-fA-F]{6}", value):
|
||||||
|
return "#FF" + value[1:]
|
||||||
|
raise ValueError(f"Unsupported SVG color: {value}")
|
||||||
|
|
||||||
|
|
||||||
|
def xml(element):
|
||||||
|
ET.indent(element, space=" ")
|
||||||
|
return HEADER + GENERATED + ET.tostring(element, encoding="unicode") + "\n"
|
||||||
|
|
||||||
|
|
||||||
|
class Artwork:
|
||||||
|
def __init__(self, master):
|
||||||
|
if master.attrib.get("viewBox") != "0 0 256 256":
|
||||||
|
raise ValueError("The master must use the 256-unit vector grid")
|
||||||
|
self.defs = master.find(f"{SVG}defs")
|
||||||
|
self.mark = master.find(f"{SVG}g[@id='mark']")
|
||||||
|
if self.defs is None or self.mark is None or not list(self.mark):
|
||||||
|
raise ValueError("The master needs defs and a nonempty mark group")
|
||||||
|
self.gradients = {g.attrib["id"]: g for g in self.defs.findall(f"{SVG}linearGradient")}
|
||||||
|
self.clips = {g.attrib["id"]: g for g in self.defs.findall(f"{SVG}clipPath")}
|
||||||
|
self.svg_defs = ET.tostring(self.defs, encoding="unicode")
|
||||||
|
self.svg_mark = ET.tostring(self.mark, encoding="unicode")
|
||||||
|
|
||||||
|
def paint(self, node, name, value):
|
||||||
|
if not value.startswith("url(#"):
|
||||||
|
node.set(ANDROID + name, color(value))
|
||||||
|
return
|
||||||
|
gradient = self.gradients[value[5:-1]]
|
||||||
|
if gradient.attrib.get("gradientUnits") != "userSpaceOnUse":
|
||||||
|
raise ValueError("Android gradients must use userSpaceOnUse")
|
||||||
|
attr = ET.SubElement(node, AAPT + "attr", {"name": "android:" + name})
|
||||||
|
out = ET.SubElement(attr, "gradient", {
|
||||||
|
ANDROID + "type": "linear",
|
||||||
|
**{ANDROID + dst: gradient.attrib[src] for src, dst in
|
||||||
|
(("x1", "startX"), ("y1", "startY"), ("x2", "endX"), ("y2", "endY"))},
|
||||||
|
})
|
||||||
|
for stop in gradient:
|
||||||
|
ET.SubElement(out, "item", {
|
||||||
|
ANDROID + "offset": stop.attrib.get("offset", "0"),
|
||||||
|
ANDROID + "color": color(stop.attrib["stop-color"]),
|
||||||
|
})
|
||||||
|
|
||||||
|
def android_node(self, source, parent, monochrome):
|
||||||
|
tag = source.tag.removeprefix(SVG)
|
||||||
|
a = source.attrib
|
||||||
|
if tag not in {"g", "path", "rect", "circle"}:
|
||||||
|
raise ValueError(f"Unsupported artwork element: {tag}")
|
||||||
|
supported = {"id", "transform", "clip-path"}
|
||||||
|
if tag != "g":
|
||||||
|
supported |= {"d", "x", "y", "width", "height", "rx", "ry", "cx", "cy", "r",
|
||||||
|
"fill", "fill-rule", "fill-opacity", "opacity", "stroke", "stroke-width",
|
||||||
|
"stroke-opacity", "stroke-linecap", "stroke-linejoin"}
|
||||||
|
if set(a) - supported:
|
||||||
|
raise ValueError(f"Unsupported {tag} attributes: {set(a) - supported}")
|
||||||
|
if "transform" in a:
|
||||||
|
match = re.fullmatch(r"translate\(\s*([-\d.]+)[ ,]+([-\d.]+)\s*\)", a["transform"])
|
||||||
|
if not match:
|
||||||
|
raise ValueError("Only explicit x/y translation is supported")
|
||||||
|
parent = ET.SubElement(parent, "group", {
|
||||||
|
ANDROID + "translateX": match[1], ANDROID + "translateY": match[2],
|
||||||
|
})
|
||||||
|
if "clip-path" in a:
|
||||||
|
clip = self.clips[a["clip-path"][5:-1]]
|
||||||
|
parent = ET.SubElement(parent, "group")
|
||||||
|
ET.SubElement(parent, "clip-path", {
|
||||||
|
ANDROID + "pathData": " ".join(shape_path(s) for s in clip),
|
||||||
|
})
|
||||||
|
if tag == "g":
|
||||||
|
for child in source:
|
||||||
|
self.android_node(child, parent, monochrome)
|
||||||
|
return
|
||||||
|
fill = a.get("fill", "#000000")
|
||||||
|
if monochrome and fill == "none":
|
||||||
|
return # Bevel highlights do not belong in the themed silhouette.
|
||||||
|
node = ET.SubElement(parent, "path", {
|
||||||
|
ANDROID + "pathData": shape_path(source),
|
||||||
|
ANDROID + "fillType": "evenOdd" if a.get("fill-rule") == "evenodd" else "nonZero",
|
||||||
|
})
|
||||||
|
self.paint(node, "fillColor", "#FFFFFF" if monochrome else fill)
|
||||||
|
if monochrome:
|
||||||
|
return
|
||||||
|
opacity = float(a.get("opacity", 1))
|
||||||
|
node.set(ANDROID + "fillAlpha", f'{opacity * float(a.get("fill-opacity", 1)):g}')
|
||||||
|
if "stroke" in a:
|
||||||
|
self.paint(node, "strokeColor", a["stroke"])
|
||||||
|
node.set(ANDROID + "strokeWidth", a.get("stroke-width", "1"))
|
||||||
|
node.set(ANDROID + "strokeAlpha", f'{opacity * float(a.get("stroke-opacity", 1)):g}')
|
||||||
|
for src, dst in (("stroke-linecap", "strokeLineCap"), ("stroke-linejoin", "strokeLineJoin")):
|
||||||
|
if src in a:
|
||||||
|
node.set(ANDROID + dst, a[src])
|
||||||
|
|
||||||
|
def vector(self, size=108, scale=.25, *, monochrome=False):
|
||||||
|
# The 256-unit canvas maps to 64dp; all painted corners stay inside
|
||||||
|
# the adaptive icon's central safe circle, including the copper rim.
|
||||||
|
root = ET.Element("vector", {
|
||||||
|
ANDROID + "width": f"{size}dp", ANDROID + "height": f"{size}dp",
|
||||||
|
ANDROID + "viewportWidth": str(size), ANDROID + "viewportHeight": str(size),
|
||||||
|
})
|
||||||
|
shift = size / 2 - 128 * scale
|
||||||
|
group = ET.SubElement(root, "group", {
|
||||||
|
ANDROID + "scaleX": str(scale), ANDROID + "scaleY": str(scale),
|
||||||
|
ANDROID + "translateX": str(shift), ANDROID + "translateY": str(shift),
|
||||||
|
})
|
||||||
|
self.android_node(self.mark, group, monochrome)
|
||||||
|
return xml(root).encode()
|
||||||
|
|
||||||
|
def ios(self):
|
||||||
|
return HEADER + GENERATED + f'''<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 256 256">
|
||||||
|
{self.svg_defs}
|
||||||
|
<rect width="256" height="256" fill="{BACKGROUND}"/>
|
||||||
|
{self.svg_mark}
|
||||||
|
</svg>
|
||||||
|
'''
|
||||||
|
|
||||||
|
def banner(self):
|
||||||
|
return HEADER + GENERATED + f'''<svg xmlns="http://www.w3.org/2000/svg" width="640" height="360" viewBox="0 0 320 180">
|
||||||
|
{self.svg_defs}
|
||||||
|
<rect width="320" height="180" fill="{BACKGROUND}"/>
|
||||||
|
<g transform="translate(8 24) scale(.5)">{self.svg_mark}</g>
|
||||||
|
<g fill="#35245D" font-family="DejaVu Sans">
|
||||||
|
<text x="140" y="82" font-size="22">Proton</text>
|
||||||
|
<text x="138" y="115" font-size="30" font-weight="bold">Stream</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--check", action="store_true", help="Verify outputs without writing files")
|
||||||
|
args = parser.parse_args()
|
||||||
|
for command in ("rsvg-convert", "magick"):
|
||||||
|
if not shutil.which(command):
|
||||||
|
parser.error(f"{command} is required")
|
||||||
|
source = ROOT / "images/logo.svg"
|
||||||
|
master = ET.parse(source).getroot()
|
||||||
|
app = master.attrib["data-app"]
|
||||||
|
if app not in {"drive", "stream", "gallery"}:
|
||||||
|
parser.error("Unknown data-app in images/logo.svg")
|
||||||
|
art = Artwork(master)
|
||||||
|
desktop = source.read_bytes()
|
||||||
|
outputs = {}
|
||||||
|
if app in {"drive", "stream"}:
|
||||||
|
slug = "proton-drive-linux" if app == "drive" else "proton-stream"
|
||||||
|
outputs[f"packaging/io.narl.{slug}.svg"] = desktop
|
||||||
|
if app == "drive":
|
||||||
|
cover = ET.parse(ROOT / "images/cover.svg").getroot()
|
||||||
|
slot = cover.find(f"{SVG}g[@id='app-logo']")
|
||||||
|
if slot is None:
|
||||||
|
raise ValueError("The cover needs an app-logo group")
|
||||||
|
for child in list(slot):
|
||||||
|
slot.remove(child)
|
||||||
|
slot.append(ET.fromstring(art.svg_defs))
|
||||||
|
slot.append(ET.fromstring(art.svg_mark))
|
||||||
|
cover_svg = xml(cover)
|
||||||
|
outputs["images/cover.svg"] = cover_svg.encode()
|
||||||
|
outputs["images/cover.png"] = render(cover_svg, 1920)
|
||||||
|
if app in {"stream", "gallery"}:
|
||||||
|
res = "android/app/src/main/res/drawable/"
|
||||||
|
outputs[res + "ic_launcher_foreground.xml"] = art.vector()
|
||||||
|
outputs[res + "ic_launcher_monochrome.xml"] = art.vector(monochrome=True)
|
||||||
|
# A full-bleed neutral surface keeps the violet object legible under
|
||||||
|
# every launcher mask. The foreground retains its own copper depth.
|
||||||
|
background = ET.Element("vector", {
|
||||||
|
ANDROID + "width": "108dp", ANDROID + "height": "108dp",
|
||||||
|
ANDROID + "viewportWidth": "108", ANDROID + "viewportHeight": "108",
|
||||||
|
})
|
||||||
|
ET.SubElement(background, "path", {
|
||||||
|
ANDROID + "fillColor": color(BACKGROUND), ANDROID + "pathData": "M0 0H108V108H0Z",
|
||||||
|
})
|
||||||
|
outputs[res + "ic_launcher_background.xml"] = xml(background).encode()
|
||||||
|
if app == "gallery":
|
||||||
|
outputs["images/icon-512.png"] = render(desktop.decode(), 512)
|
||||||
|
outputs["android/app/src/main/res/drawable/ic_gallery.xml"] = art.vector(256, 1)
|
||||||
|
if app == "stream":
|
||||||
|
outputs["android/app/src/main/res/drawable/ic_notification_stream.xml"] = art.vector(24, 24/256, monochrome=True)
|
||||||
|
outputs["crates/pstr-app/assets/icon-256.png"] = render(desktop.decode(), 256)
|
||||||
|
ios = art.ios()
|
||||||
|
outputs["ios/ProtonStream/Resources/AppIcon.svg"] = ios.encode()
|
||||||
|
outputs["ios/ProtonStream/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png"] = render(ios, 1024, opaque=True)
|
||||||
|
with tempfile.TemporaryDirectory(prefix="proton-icons-") as temp:
|
||||||
|
files = []
|
||||||
|
for size in (16, 24, 32, 48, 64, 128, 256):
|
||||||
|
path = Path(temp) / f"{size}.png"
|
||||||
|
path.write_bytes(render(desktop.decode(), size))
|
||||||
|
files.append(str(path))
|
||||||
|
outputs["packaging/windows/proton-stream.ico"] = run("magick", *files, "-strip", "ICO:-")
|
||||||
|
if not shutil.which("fc-match"):
|
||||||
|
parser.error("fontconfig is required to render the Android TV banner")
|
||||||
|
if "DejaVu Sans" not in run("fc-match", "-f", "%{family}", "DejaVu Sans").decode():
|
||||||
|
parser.error("DejaVu Sans is required to render the Android TV banner")
|
||||||
|
outputs["android/app/src/main/res/drawable-nodpi/tv_banner.png"] = render(art.banner(), 640, opaque=True)
|
||||||
|
stale = []
|
||||||
|
for relative, data in outputs.items():
|
||||||
|
target = ROOT / relative
|
||||||
|
if target.exists() and target.read_bytes() == data:
|
||||||
|
continue
|
||||||
|
if args.check:
|
||||||
|
stale.append(relative)
|
||||||
|
else:
|
||||||
|
target.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
target.write_bytes(data)
|
||||||
|
print(f"wrote {relative}")
|
||||||
|
if stale:
|
||||||
|
parser.exit(1, "Branding assets need regeneration:\n" + "\n".join(stale) + "\n")
|
||||||
|
print(f"{'Verified' if args.check else 'Rendered'} {len(outputs)} assets from images/logo.svg")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -22,6 +22,7 @@ Options:
|
|||||||
with its scripts/sync-screenshots.sh
|
with its scripts/sync-screenshots.sh
|
||||||
--settle SECS how long a page gets to load before its capture (default 3)
|
--settle SECS how long a page gets to load before its capture (default 3)
|
||||||
--debug use a debug build instead of a release build
|
--debug use a debug build instead of a release build
|
||||||
|
--skip-build reuse binaries from the selected profile
|
||||||
--keep keep the temporary directory, for a look at the logs
|
--keep keep the temporary directory, for a look at the logs
|
||||||
|
|
||||||
Needs cage, grim, wlr-randr, ImageMagick, dbus-run-session and
|
Needs cage, grim, wlr-randr, ImageMagick, dbus-run-session and
|
||||||
@@ -45,8 +46,19 @@ if [[ "${1:-}" == --capture ]]; then
|
|||||||
output() { wlr-randr --output "$(wlr-randr | awk 'NR==1 {print $1}')" --custom-mode "$1"; }
|
output() { wlr-randr --output "$(wlr-randr | awk 'NR==1 {print $1}')" --custom-mode "$1"; }
|
||||||
shoot() {
|
shoot() {
|
||||||
sleep "$SETTLE"
|
sleep "$SETTLE"
|
||||||
grim "$OUT/$1.png"
|
# Cold GTK/portal startup can leave the compositor black briefly.
|
||||||
echo "captured $1"
|
# Wait for actual window content rather than publishing a blank PNG.
|
||||||
|
local capture_try
|
||||||
|
for capture_try in 1 2 3 4 5; do
|
||||||
|
grim "$OUT/$1.png"
|
||||||
|
if [[ "$(magick "$OUT/$1.png" -format '%[fx:standard_deviation>0.001]' info:)" == 1 ]]; then
|
||||||
|
echo "captured $1"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo "no window content for $1; screenshot is blank" >&2
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
# Cut the compositor's black background off a window smaller than it.
|
# Cut the compositor's black background off a window smaller than it.
|
||||||
trim() {
|
trim() {
|
||||||
@@ -127,6 +139,7 @@ shots=$all
|
|||||||
website=
|
website=
|
||||||
settle=3
|
settle=3
|
||||||
profile=release
|
profile=release
|
||||||
|
skip_build=
|
||||||
keep=
|
keep=
|
||||||
while (($#)); do
|
while (($#)); do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -135,6 +148,7 @@ while (($#)); do
|
|||||||
--website) website=$(realpath -- "${2:?}"); shift ;;
|
--website) website=$(realpath -- "${2:?}"); shift ;;
|
||||||
--settle) settle=${2:?}; shift ;;
|
--settle) settle=${2:?}; shift ;;
|
||||||
--debug) profile=debug ;;
|
--debug) profile=debug ;;
|
||||||
|
--skip-build) skip_build=1 ;;
|
||||||
--keep) keep=1 ;;
|
--keep) keep=1 ;;
|
||||||
-h | --help) usage ;;
|
-h | --help) usage ;;
|
||||||
*) echo "unknown option: $1" >&2; usage ;;
|
*) echo "unknown option: $1" >&2; usage ;;
|
||||||
@@ -163,11 +177,17 @@ done
|
|||||||
|
|
||||||
cargo_flags=(--manifest-path "$repo/Cargo.toml" --locked)
|
cargo_flags=(--manifest-path "$repo/Cargo.toml" --locked)
|
||||||
[[ "$profile" == release ]] && cargo_flags+=(--release)
|
[[ "$profile" == release ]] && cargo_flags+=(--release)
|
||||||
cargo build "${cargo_flags[@]}" -p pdfs-gui --bin pdfs-app --bin pdfs-prompt
|
if [[ -z "$skip_build" ]]; then
|
||||||
cargo build "${cargo_flags[@]}" -p pdfs-core --example demo_daemon
|
cargo build "${cargo_flags[@]}" -p pdfs-gui --bin pdfs-app --bin pdfs-prompt
|
||||||
|
cargo build "${cargo_flags[@]}" -p pdfs-core --example demo_daemon
|
||||||
|
fi
|
||||||
target=$(cargo metadata --manifest-path "$repo/Cargo.toml" --format-version 1 --no-deps |
|
target=$(cargo metadata --manifest-path "$repo/Cargo.toml" --format-version 1 --no-deps |
|
||||||
python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])')
|
python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])')
|
||||||
bin="$(mktemp -d)"
|
bin="$(mktemp -d)"
|
||||||
|
for executable in "$target/$profile/pdfs-app" "$target/$profile/pdfs-prompt" \
|
||||||
|
"$target/$profile/examples/demo_daemon"; do
|
||||||
|
[[ -x "$executable" ]] || { echo "missing executable: $executable; run without --skip-build" >&2; exit 2; }
|
||||||
|
done
|
||||||
ln -s "$target/$profile/pdfs-app" "$target/$profile/pdfs-prompt" \
|
ln -s "$target/$profile/pdfs-app" "$target/$profile/pdfs-prompt" \
|
||||||
"$target/$profile/examples/demo_daemon" "$bin/"
|
"$target/$profile/examples/demo_daemon" "$bin/"
|
||||||
|
|
||||||
@@ -182,6 +202,9 @@ chmod 700 "$root/run"
|
|||||||
# The user's own fonts, so the shots look like the app does here.
|
# The user's own fonts, so the shots look like the app does here.
|
||||||
mkdir -p "$root/data/fonts"
|
mkdir -p "$root/data/fonts"
|
||||||
[[ -d "$HOME/.local/share/fonts" ]] && cp -rs "$HOME/.local/share/fonts/." "$root/data/fonts/"
|
[[ -d "$HOME/.local/share/fonts" ]] && cp -rs "$HOME/.local/share/fonts/." "$root/data/fonts/"
|
||||||
|
# Prefer this checkout's brand over an older icon from an installed package.
|
||||||
|
install -Dm644 "$repo/packaging/io.narl.proton-drive-linux.svg" \
|
||||||
|
"$root/data/icons/hicolor/scalable/apps/io.narl.proton-drive-linux.svg"
|
||||||
mkdir -p "$root/config/proton-drive-linux"
|
mkdir -p "$root/config/proton-drive-linux"
|
||||||
cat >"$root/config/proton-drive-linux/config.json" <<'EOF'
|
cat >"$root/config/proton-drive-linux/config.json" <<'EOF'
|
||||||
{
|
{
|
||||||
|
|||||||