Merge pull request #105 from narrrl/feat/branding

Feat/branding
This commit is contained in:
nvrl authored and GitHub committed 2026-11-19 01:13:39 +01:00
commit 7d9d5850a4
23 files changed
+301 -71

No files matched your search

Generated
+4 -4
View File
@@ -3582,7 +3582,7 @@ checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
[[package]]
name = "pdfs-cli"
version = "3.8.0"
version = "3.8.1"
dependencies = [
"anyhow",
"clap",
@@ -3599,7 +3599,7 @@ dependencies = [
[[package]]
name = "pdfs-core"
version = "3.8.0"
version = "3.8.1"
dependencies = [
"async-trait",
"base64 0.23.1",
@@ -3629,7 +3629,7 @@ dependencies = [
[[package]]
name = "pdfs-fuse"
version = "3.8.0"
version = "3.8.1"
dependencies = [
"async-trait",
"base64 0.23.1",
@@ -3653,7 +3653,7 @@ dependencies = [
[[package]]
name = "pdfs-gui"
version = "3.8.0"
version = "3.8.1"
dependencies = [
"anyhow",
"async-channel",
+1 -1
View File
@@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/pdfs-core", "crates/pdfs-fuse", "crates/pdfs-cli", "crates/pdfs-gui"]
[workspace.package]
version = "3.8.0"
version = "3.8.1"
edition = "2024"
license = "MIT"
authors = ["Nils Pukropp <contact@narl.io>"]
+71 -34
View File
@@ -579,6 +579,7 @@ impl ContentCache {
// the disk.
cache.reseed_totals();
cache.import_legacy_pins()?;
cache.set_budget(max_bytes);
Ok(cache)
}
@@ -1153,16 +1154,18 @@ impl ContentCache {
};
let mut skipped = 0usize;
while running > cap {
// Fetch a batch past whatever we have already skipped as exempt.
let want = skipped + EVICT_BATCH;
let Ok(batch) = self.db.cache_eviction_candidates(kind, want) else {
// A whole batch can be pinned. Keep looking until the index has
// no entries past the ones we have skipped.
let Ok(batch) = self
.db
.cache_eviction_candidates(kind, EVICT_BATCH, skipped)
else {
break;
};
if batch.len() <= skipped {
break; // nothing new to consider
if batch.is_empty() {
break;
}
let mut evicted_any = false;
for (key, size) in batch.into_iter().skip(skipped) {
for (key, size) in batch {
if running <= cap {
break;
}
@@ -1170,14 +1173,18 @@ impl ContentCache {
skipped += 1; // counts toward the total, never a victim
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 _ = self.db.cache_remove(&key);
if self.db.cache_remove(&key).is_err() {
skipped += 1;
continue;
}
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.
@@ -1405,7 +1412,7 @@ impl ContentCache {
.collect();
let content_dir = self.content_dir.clone();
// 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;
};
for (key, bytes) in list {
@@ -1883,13 +1890,13 @@ impl ContentCache {
// Pinned blobs (by cache key) are exempt from eviction. Resolves direct
// pins plus every descendant of a recursively-pinned folder, hashed into
// cache keys to match on-disk filenames.
let pinned: HashSet<String> = self
.db
.pinned_uids()
.unwrap_or_default()
.iter()
.map(|uid| Self::key_str(uid))
.collect();
let pinned = match self.db.pinned_uids() {
Ok(uids) => uids.iter().map(|uid| Self::key_str(uid)).collect(),
Err(error) => {
tracing::warn!(%error, "reading pins for cache eviction failed");
return;
}
};
let content_dir = self.content_dir.clone();
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
/// enforce it: blobs and blocks are LRU-evicted back under the new cap (a
/// lower cap frees space now; a higher one is a no-op until the next store).
/// enforce it across all three pools.
/// Called by the daemon when the Settings page changes the cache budget.
pub fn set_budget(&self, bytes: u64) {
self.max_bytes.store(bytes, Ordering::Relaxed);
@@ -2245,19 +2251,50 @@ mod tests {
// crash) but the same on-disk cache: reconcile repopulates from disk.
let db2 = Arc::new(Db::open_in_memory().unwrap());
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);
// With the index rebuilt, a further store enforces the budget against the
// reconciled entries instead of leaking them.
c.store(&uid("d"), 1, 4, b"dddd").unwrap();
let total: u64 = db2
.cache_entries_by_kind("blob")
.unwrap()
.iter()
.map(|(_, s)| s)
.sum();
assert!(total <= 8, "budget enforced after reconcile, total={total}");
assert_eq!(c.usage(), 12);
}
#[test]
fn reopening_trims_all_cache_pools_even_when_the_oldest_batch_is_pinned() {
let (c, _dir) = cache();
for i in 0..EVICT_BATCH {
let u = uid(&format!("pinned-{i}"));
c.store(&u, 1, 1, b"p").unwrap();
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
+5 -3
View File
@@ -108,7 +108,8 @@ impl Db {
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
/// pass over a large cache does not read every row to drop a few, and so the
@@ -118,13 +119,14 @@ impl Db {
&self,
kind: &str,
limit: usize,
offset: usize,
) -> Result<Vec<(String, u64)>> {
let conn = self.read();
let mut stmt = conn.prepare_cached(
"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))
})?;
let mut out = Vec::new();
+58 -10
View File
@@ -252,9 +252,32 @@ const UID_NOW: &str = "COALESCE((SELECT uid FROM nodes WHERE lid = pending_op.li
const PARENT_NOW: &str =
"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
/// claimed already, no other claimed op on the same node, and not under a
/// folder that has yet to land.
/// claimed already, no other claimed op on the same node, no pending creation
/// 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
/// 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 uid NOT IN (SELECT uid FROM pending_op WHERE claimed_at <> 0)
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,
n = LOCAL_VOLUME.len() + 1,
)
@@ -475,19 +500,40 @@ pub struct AttachedBlob {
}
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
/// 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
/// wait for the trash rather than land under a conflict name.
pub fn has_pending_trash_named(&self, name: &str) -> Result<bool> {
/// wait for the trash rather than land under a conflict name. Older rows
/// 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();
conn.query_row(
"SELECT EXISTS(
SELECT 1 FROM pending_op WHERE kind = ?1 AND name = ?2
)",
params![OP_TRASH, name],
SELECT 1 FROM pending_op AS p
WHERE p.kind = ?1 AND p.name = ?2
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),
)
.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
/// 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.
/// * 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
/// order for free — the older op is claimed first and the newer one is
/// 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
/// row as unclaimed.
+72 -5
View File
@@ -2740,15 +2740,34 @@ fn atomic_trash_replacement_returns_owned_blobs_after_commit() {
#[test]
fn a_queued_trash_holds_its_name_until_it_lands() {
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();
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();
assert!(db.has_pending_trash_named("report.txt").unwrap());
assert!(!db.has_pending_trash_named("other.txt").unwrap());
assert!(
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();
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
@@ -6094,7 +6113,7 @@ fn cache_eviction_candidates_are_lru_ordered_and_limited() {
}
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");
let keys: Vec<&str> = batch.iter().map(|(k, _)| k.as_str()).collect();
assert_eq!(keys, ["k9", "k8", "k7"], "least-recently-accessed first");
@@ -6925,6 +6944,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]
fn claims_do_not_survive_the_process_that_took_them() {
let db = Db::open_in_memory().unwrap();
+5 -1
View File
@@ -1349,7 +1349,11 @@ impl Core {
parent: Option<&NodeUid>,
name: &str,
) -> 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);
}
if op.attempts >= NAME_HOLD_ATTEMPTS {
+8 -6
View File
@@ -2372,17 +2372,19 @@ impl ProtonFs {
}
}
}
// Offline: queue it. Trashing is the one mutation a user expects to work
// regardless — the file is gone from their point of view the moment the
// command returns. The same when the network goes
// away under the remote call below.
// Queue a folder trash while Drive still holds children that were moved
// out locally. The drain waits for those moves before sending it.
let queue_it = |reply: ReplyEmpty| match self.core.queue_trash(&uid, name, open_now) {
Ok(()) => reply.ok(),
Err(e) => reply.error(e),
};
if !self.core.sends_inline() {
queue_it(reply);
return;
return queue_it(reply);
}
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) {
reply.error(e);
+18 -2
View File
@@ -4012,6 +4012,15 @@ impl Core {
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
/// now.
///
@@ -5390,6 +5399,11 @@ impl Core {
&parent_uid,
)
.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
.block_on(self.drive.trash_nodes(std::slice::from_ref(&uid)))
.and_then(batch::into_unit)
@@ -5454,11 +5468,13 @@ impl Core {
} else {
uid
};
// Local-first or offline, or the network goes away under the call:
// queue the trash. The rename that follows queues as well, behind it.
// Local-first or offline: queue the trash and the rename that follows.
if !self.sends_inline() {
return self.queue_trash(uid, name, open);
}
if self.has_pending_moves_out_of(uid)? {
return Err(Errno::EBUSY);
}
self.require_uid_writable(uid)?;
if let Err(e) = self
.block_on_bounded(self.drive.trash_nodes(std::slice::from_ref(uid)))
+20
View File
@@ -419,6 +419,10 @@ impl Tray for DriveTray {
self.state.phase.icon().into()
}
fn attention_icon_name(&self) -> String {
self.icon_name()
}
fn status(&self) -> Status {
match self.state.phase {
Phase::Attention | Phase::SessionExpired => Status::NeedsAttention,
@@ -672,6 +676,22 @@ mod tests {
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 {
status_from(env!("CARGO_PKG_VERSION"), extra)
}
+10
View File
@@ -11,6 +11,16 @@ scratch (user data in `staging/` and `recovery/` is never touched by this).
## [Unreleased]
## [3.8.1] — 2026-11-19
### Added
- **Branding** icons updated, screenshots updated
### Fixed
- **Cache Eviction** fixed an issue where it didn't scan past pinned files and now also reapplies the limit at startup.
## [3.8.0] — 2026-11-14
Schema: **45**. Synced folders now tell device backups apart from folders attached to My files.
+1
View File
@@ -167,6 +167,7 @@ invented account, so they never show anyone's files:
```bash
scripts/screenshots.sh # all of them, into images/
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
```
Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 138 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 115 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 33 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 KiB

After

Width:  |  Height:  |  Size: 283 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 96 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 97 KiB

+1 -1
View File
@@ -9,7 +9,7 @@
# Build + install: cd packaging && makepkg -fi
pkgname=proton-drive-linux
pkgver=3.8.0
pkgver=3.8.1
pkgrel=1
pkgdesc="Unofficial Proton Drive client for Linux: files-on-demand FUSE mount, CLI, GTK4 app + tray"
arch=('x86_64')
+27 -4
View File
@@ -22,6 +22,7 @@ Options:
with its scripts/sync-screenshots.sh
--settle SECS how long a page gets to load before its capture (default 3)
--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
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"; }
shoot() {
sleep "$SETTLE"
grim "$OUT/$1.png"
echo "captured $1"
# Cold GTK/portal startup can leave the compositor black briefly.
# 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.
trim() {
@@ -127,6 +139,7 @@ shots=$all
website=
settle=3
profile=release
skip_build=
keep=
while (($#)); do
case "$1" in
@@ -135,6 +148,7 @@ while (($#)); do
--website) website=$(realpath -- "${2:?}"); shift ;;
--settle) settle=${2:?}; shift ;;
--debug) profile=debug ;;
--skip-build) skip_build=1 ;;
--keep) keep=1 ;;
-h | --help) usage ;;
*) echo "unknown option: $1" >&2; usage ;;
@@ -163,11 +177,17 @@ done
cargo_flags=(--manifest-path "$repo/Cargo.toml" --locked)
[[ "$profile" == release ]] && cargo_flags+=(--release)
cargo build "${cargo_flags[@]}" -p pdfs-gui --bin pdfs-app --bin pdfs-prompt
cargo build "${cargo_flags[@]}" -p pdfs-core --example demo_daemon
if [[ -z "$skip_build" ]]; then
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 |
python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])')
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" \
"$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.
mkdir -p "$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"
cat >"$root/config/proton-drive-linux/config.json" <<'EOF'
{