mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-22 02:33:31 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b5d6f2436 |
No files matched your search
Generated
+4
-4
@@ -3952,9 +3952,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proton-drive-rs"
|
||||
version = "0.12.4"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "670bfcf0eeb15886c962c18c76dbac976236e4377bfe073eb2360dc1ce448da2"
|
||||
checksum = "e9f7e67c864033e2d13ff48f9e0738f22ae6401cc47131b266b90c23e0dcc381"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.23.1",
|
||||
@@ -4060,9 +4060,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proton-sdk"
|
||||
version = "0.12.4"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f578a9d920cef3f6c4da611793001fe6d2ed81face13c45f5e721274b1945f7d"
|
||||
checksum = "a443d600225687a92724b455c025a049b8668fe9da52fbf7cb46583a8e4970a7"
|
||||
dependencies = [
|
||||
"aes-gcm 0.11.1",
|
||||
"async-trait",
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@ keywords = ["proton", "drive", "fuse", "sync", "linux"]
|
||||
categories = ["filesystem", "command-line-utilities"]
|
||||
|
||||
[workspace.dependencies]
|
||||
proton-sdk = { version = "0.12.4" }
|
||||
proton-drive-rs = { version = "0.12.4" }
|
||||
proton-sdk = { version = "0.12.3" }
|
||||
proton-drive-rs = { version = "0.12.3" }
|
||||
proton-gallery-app-rs = "0.1.0"
|
||||
proton-gallery-rs = "0.1.5"
|
||||
chrono = { version = "0.4", default-features = false, features = ["std"] }
|
||||
|
||||
+102
-5
@@ -158,8 +158,12 @@ enum Command {
|
||||
#[arg(long)]
|
||||
forget: bool,
|
||||
},
|
||||
/// Forget the stored session.
|
||||
Logout,
|
||||
/// Forget the stored session. Asks first while changes are still queued.
|
||||
Logout {
|
||||
/// Do not ask first.
|
||||
#[arg(long)]
|
||||
yes: bool,
|
||||
},
|
||||
/// Show account login state, and mount status if a daemon is running.
|
||||
Status,
|
||||
/// List every local Proton Drive location.
|
||||
@@ -857,6 +861,13 @@ enum SyncCmd {
|
||||
},
|
||||
/// List uploads and changes not yet on Proton Drive.
|
||||
Queue,
|
||||
/// Wait until every queued change is on Proton Drive. Exits 0 once nothing
|
||||
/// is left, 3 when what is left needs you (see `sync issues`), 4 on timeout.
|
||||
Flush {
|
||||
/// Give up after this many seconds.
|
||||
#[arg(long)]
|
||||
timeout: Option<u64>,
|
||||
},
|
||||
/// List queued changes Proton Drive refused or that keep failing, and what to do.
|
||||
Issues,
|
||||
/// Save the content of a queued upload (by id from `sync queue`) to a file.
|
||||
@@ -1047,7 +1058,7 @@ fn main() -> Result<()> {
|
||||
cli.command,
|
||||
Command::Login { .. }
|
||||
| Command::Unlock { .. }
|
||||
| Command::Logout
|
||||
| Command::Logout { .. }
|
||||
| Command::Mount { .. }
|
||||
| Command::Daemon { .. }
|
||||
) {
|
||||
@@ -1057,7 +1068,7 @@ fn main() -> Result<()> {
|
||||
Command::Login { username, remember } => cmd_login(username, remember),
|
||||
Command::Unlock { remember } => cmd_unlock(remember),
|
||||
Command::Lock { forget } => cmd_lock(forget),
|
||||
Command::Logout => cmd_logout(),
|
||||
Command::Logout { yes } => cmd_logout(yes),
|
||||
Command::Status => cmd_status(),
|
||||
Command::Locations => cmd_locations(),
|
||||
Command::Mount { mountpoint } => cmd_mount(mountpoint),
|
||||
@@ -1362,6 +1373,7 @@ fn cmd_sync(action: SyncCmd) -> Result<()> {
|
||||
})?)?
|
||||
}
|
||||
SyncCmd::Queue => return cmd_sync_queue(),
|
||||
SyncCmd::Flush { timeout } => return cmd_sync_flush(timeout),
|
||||
SyncCmd::Issues => return cmd_sync_issues(),
|
||||
SyncCmd::Export { id, dest } => return cmd_sync_export(id, &dest),
|
||||
SyncCmd::Limit { up, down } => return cmd_sync_limit(up, down),
|
||||
@@ -1465,6 +1477,71 @@ fn cmd_sync_queue() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `pdfs sync flush`: wait for the queue to drain.
|
||||
///
|
||||
/// Failed changes are retried at once rather than after their backoff. The
|
||||
/// wait ends early, with exit code 3, when everything left is waiting on the
|
||||
/// user: refused by Drive, failing again and again, or a temporary file
|
||||
/// waiting for its final name. Paused or offline, it keeps waiting and says
|
||||
/// why.
|
||||
fn cmd_sync_flush(timeout: Option<u64>) -> Result<()> {
|
||||
const POLL: std::time::Duration = std::time::Duration::from_secs(1);
|
||||
let deadline =
|
||||
timeout.map(|secs| std::time::Instant::now() + std::time::Duration::from_secs(secs));
|
||||
ok_or_bail(control_request(CtlRequest::RetryPendingOp { id: None })?)?;
|
||||
let mut last_line = String::new();
|
||||
loop {
|
||||
let items = match control_request(CtlRequest::ListPendingOps)? {
|
||||
CtlResponse::PendingOps { items } => items,
|
||||
CtlResponse::Error { message, kind } => bail!("{}", cli_error(kind, &message)),
|
||||
other => bail!("unexpected response: {other:?}"),
|
||||
};
|
||||
let waiting = items
|
||||
.iter()
|
||||
.filter(|op| !op.parked && !op.failing && op.issue.is_none())
|
||||
.count();
|
||||
if items.is_empty() {
|
||||
finish_line(&last_line);
|
||||
println!("Everything is on Proton Drive.");
|
||||
return Ok(());
|
||||
}
|
||||
if waiting == 0 {
|
||||
finish_line(&last_line);
|
||||
eprintln!(
|
||||
"{} queued change(s) need you before they can be sent. See `pdfs sync issues`.",
|
||||
items.len()
|
||||
);
|
||||
std::process::exit(3);
|
||||
}
|
||||
let reason = match control_request(CtlRequest::Status)? {
|
||||
CtlResponse::Status { paused: true, .. } => " (sync is paused; `pdfs sync resume`)",
|
||||
CtlResponse::Status { online: false, .. } => " (offline; waiting for Proton Drive)",
|
||||
_ => "",
|
||||
};
|
||||
let line = format!("{waiting} change(s) left to send{reason}");
|
||||
if line != last_line {
|
||||
if !last_line.is_empty() {
|
||||
print!("\r\x1b[2K");
|
||||
}
|
||||
print!("{line}");
|
||||
last_line = line;
|
||||
}
|
||||
if deadline.is_some_and(|deadline| std::time::Instant::now() >= deadline) {
|
||||
finish_line(&last_line);
|
||||
eprintln!("Timed out with {waiting} change(s) still queued.");
|
||||
std::process::exit(4);
|
||||
}
|
||||
std::thread::sleep(POLL);
|
||||
}
|
||||
}
|
||||
|
||||
/// End a progress line so the next message starts on its own.
|
||||
fn finish_line(last_line: &str) {
|
||||
if !last_line.is_empty() {
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
||||
/// `pdfs sync issues`: the queued changes that need the user, and what to do.
|
||||
fn cmd_sync_issues() -> Result<()> {
|
||||
let response = control_request(CtlRequest::ListPendingOps)?;
|
||||
@@ -2298,7 +2375,27 @@ fn key_state_name() -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
fn cmd_logout() -> Result<()> {
|
||||
fn cmd_logout(yes: bool) -> Result<()> {
|
||||
// Queued changes stay staged on this computer and are sent after the next
|
||||
// sign-in, but until then they exist nowhere else. Without a running
|
||||
// daemon there is no count to show.
|
||||
if !yes
|
||||
&& let Ok(CtlResponse::Status {
|
||||
pending_uploads,
|
||||
pending_changes,
|
||||
parked_uploads,
|
||||
..
|
||||
}) = control_request(CtlRequest::Status)
|
||||
{
|
||||
let queued = pending_uploads + pending_changes + parked_uploads;
|
||||
if queued > 0 {
|
||||
println!(
|
||||
"{queued} change(s) are not on Proton Drive yet. They stay on this computer and are \
|
||||
sent after you sign in again. Run `pdfs sync flush` first to send them now."
|
||||
);
|
||||
confirm("Sign out anyway?")?;
|
||||
}
|
||||
}
|
||||
if auth::logout()? {
|
||||
println!("Signed out: the session is ended on Proton and cleared here.");
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
//! Hold off a shutdown while queued changes exist only on this computer.
|
||||
//!
|
||||
//! A change made through the mount is staged here and sent by the drain. Until
|
||||
//! it lands, this computer has the only copy, so powering off then risks it
|
||||
//! more than the user expects (`docs/BUGS.md` B66). While the queue holds work
|
||||
//! the drain can still send, the daemon takes a logind shutdown inhibitor
|
||||
//! through `systemd-inhibit`, which desktops show in their power-off dialog
|
||||
//! with the reason. It is let go as soon as the queue empties.
|
||||
//!
|
||||
//! Work that cannot drain on its own — a temporary file waiting for its final
|
||||
//! name, or a change Drive refused or that keeps failing — never holds the
|
||||
//! lock, or a shutdown would be held up for something that is not coming.
|
||||
//! Without `systemd-inhibit` nothing happens.
|
||||
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::time::Duration;
|
||||
|
||||
use pdfs_core::db::PendingCounts;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use super::Core;
|
||||
|
||||
/// How often the queue is looked at.
|
||||
const CHECK_EVERY: Duration = Duration::from_secs(5);
|
||||
|
||||
/// Changes the drain can still send by itself.
|
||||
fn sendable(counts: &PendingCounts) -> i64 {
|
||||
(counts.uploads + counts.changes - counts.parked - counts.failing).max(0)
|
||||
}
|
||||
|
||||
/// Run until the daemon stops, holding the inhibitor while changes wait.
|
||||
pub(crate) fn run(core: Core) {
|
||||
let mut held: Option<Child> = None;
|
||||
loop {
|
||||
let waiting = core
|
||||
.db
|
||||
.pending_op_counts()
|
||||
.map(|counts| sendable(&counts))
|
||||
.unwrap_or(0);
|
||||
// The helper can go away (logind restarted, or it was killed); the
|
||||
// lock is then taken again on the next round.
|
||||
if let Some(child) = &mut held
|
||||
&& !matches!(child.try_wait(), Ok(None))
|
||||
{
|
||||
held = None;
|
||||
}
|
||||
match (&mut held, waiting > 0) {
|
||||
(None, true) => held = take(waiting),
|
||||
(Some(child), false) => {
|
||||
release(child);
|
||||
held = None;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if !core.shutdown.sleep(CHECK_EVERY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if let Some(mut child) = held {
|
||||
release(&mut child);
|
||||
}
|
||||
}
|
||||
|
||||
fn take(waiting: i64) -> Option<Child> {
|
||||
let why = if waiting == 1 {
|
||||
"Sending 1 change to Proton Drive".to_string()
|
||||
} else {
|
||||
format!("Sending {waiting} changes to Proton Drive")
|
||||
};
|
||||
match Command::new("systemd-inhibit")
|
||||
.args([
|
||||
"--what=shutdown",
|
||||
"--who=Proton Drive",
|
||||
&format!("--why={why}"),
|
||||
"--mode=block",
|
||||
"sleep",
|
||||
"infinity",
|
||||
])
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()
|
||||
{
|
||||
Ok(child) => {
|
||||
debug!(waiting, "holding off shutdown while changes are queued");
|
||||
Some(child)
|
||||
}
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => None,
|
||||
Err(error) => {
|
||||
warn!(%error, "taking the shutdown inhibitor failed");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn release(child: &mut Child) {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
debug!("queue drained; shutdown no longer held off");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn counts(uploads: i64, changes: i64, parked: i64, failing: i64) -> PendingCounts {
|
||||
PendingCounts {
|
||||
uploads,
|
||||
changes,
|
||||
parked,
|
||||
failing,
|
||||
last_error: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_work_the_drain_can_send_holds_off_a_shutdown() {
|
||||
assert_eq!(sendable(&counts(0, 0, 0, 0)), 0);
|
||||
assert_eq!(sendable(&counts(2, 1, 0, 0)), 3);
|
||||
assert_eq!(sendable(&counts(1, 0, 1, 0)), 0);
|
||||
assert_eq!(sendable(&counts(2, 0, 0, 2)), 0);
|
||||
assert_eq!(sendable(&counts(3, 2, 1, 1)), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn counts_that_overlap_never_go_negative() {
|
||||
assert_eq!(sendable(&counts(1, 0, 1, 1)), 0);
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ use drive::{DriveApi, RevisionRead};
|
||||
mod events;
|
||||
mod filesystem;
|
||||
mod gallery;
|
||||
mod inhibit;
|
||||
mod keeper;
|
||||
mod link;
|
||||
pub use filesystem::ProtonFs;
|
||||
|
||||
@@ -793,6 +793,17 @@ pub(crate) fn mount_with(
|
||||
warn!(%error, "start My Files share-id repair failed");
|
||||
}
|
||||
}
|
||||
// Hold off a shutdown while changes exist only here (B66). Only the real
|
||||
// daemon: a simulation's queue is not the user's data.
|
||||
if matches!(host, Host::Daemon) {
|
||||
let inhibit_core = core.clone();
|
||||
if let Err(error) = std::thread::Builder::new()
|
||||
.name("pdfs-inhibit".into())
|
||||
.spawn(move || crate::inhibit::run(inhibit_core))
|
||||
{
|
||||
warn!(%error, "start the shutdown inhibitor failed");
|
||||
}
|
||||
}
|
||||
|
||||
// Stop signals (SIGTERM from `systemctl --user stop`, SIGINT from Ctrl-C)
|
||||
// are delivered onto the async runtime; bridge them onto a sync channel so
|
||||
|
||||
+80
-217
@@ -256,62 +256,6 @@ impl Reporter {
|
||||
}
|
||||
}
|
||||
|
||||
/// Photos uploaded at once. Each upload waits on Proton between its blocks,
|
||||
/// so two keep the link busy where one leaves it idle; more would mostly
|
||||
/// stage more copies on disk.
|
||||
const IMPORT_UPLOADS: usize = 2;
|
||||
|
||||
/// Where an upload reads the photo from.
|
||||
enum Source<'a> {
|
||||
/// A copy staged on disk, which a thumbnail can be made from.
|
||||
Staged(&'a Path),
|
||||
/// Straight out of the open archive.
|
||||
Archive(&'a mut zip::ZipArchive<std::io::BufReader<std::fs::File>>),
|
||||
}
|
||||
|
||||
/// A staged photo handed to an upload worker.
|
||||
struct Upload {
|
||||
index: usize,
|
||||
path: PathBuf,
|
||||
photo: TakeoutPhoto,
|
||||
tags: Vec<PhotoTag>,
|
||||
main_uid: Option<NodeUid>,
|
||||
}
|
||||
|
||||
impl Upload {
|
||||
fn landed(self, result: CoreResult<NodeUid>) -> Landed {
|
||||
Landed {
|
||||
index: self.index,
|
||||
live: self.main_uid.is_some(),
|
||||
photo: self.photo,
|
||||
result,
|
||||
}
|
||||
}
|
||||
|
||||
fn streamed(
|
||||
index: usize,
|
||||
photo: TakeoutPhoto,
|
||||
main_uid: Option<NodeUid>,
|
||||
result: CoreResult<NodeUid>,
|
||||
) -> Landed {
|
||||
Landed {
|
||||
index,
|
||||
live: main_uid.is_some(),
|
||||
photo,
|
||||
result,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A finished upload, to be counted on the import thread.
|
||||
struct Landed {
|
||||
index: usize,
|
||||
/// The video of a live pair, filed with its still.
|
||||
live: bool,
|
||||
photo: TakeoutPhoto,
|
||||
result: CoreResult<NodeUid>,
|
||||
}
|
||||
|
||||
/// How a planned photo relates to a live or motion photo pair.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum LiveRole {
|
||||
@@ -770,133 +714,72 @@ impl Core {
|
||||
}
|
||||
}
|
||||
|
||||
// Staged photos go to IMPORT_UPLOADS workers while this thread
|
||||
// reads the next one out of its archive. A round ends only when
|
||||
// every upload in it has landed, so a pair's video always finds
|
||||
// its still's uid.
|
||||
let (jobs, queue) = std::sync::mpsc::sync_channel::<Upload>(0);
|
||||
let queue = std::sync::Mutex::new(queue);
|
||||
std::thread::scope(|scope| {
|
||||
let (landed_tx, landed) = std::sync::mpsc::channel::<Landed>();
|
||||
for _ in 0..IMPORT_UPLOADS {
|
||||
let queue = &queue;
|
||||
let landed_tx = landed_tx.clone();
|
||||
scope.spawn(move || {
|
||||
loop {
|
||||
let next = queue.lock().map(|queue| queue.recv());
|
||||
let Ok(Ok(upload)) = next else { break };
|
||||
let result = self.upload_takeout_photo(
|
||||
Source::Staged(&upload.path),
|
||||
&upload.photo,
|
||||
upload.tags.clone(),
|
||||
upload.main_uid.clone(),
|
||||
);
|
||||
let _ = std::fs::remove_file(&upload.path);
|
||||
if landed_tx.send(upload.landed(result)).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
for (archive_index, indices) in by_archive {
|
||||
if self.import_should_stop(cancel) {
|
||||
stopped = true;
|
||||
break;
|
||||
}
|
||||
drop(landed_tx);
|
||||
let mut archive = match open_archive(archives, archive_index) {
|
||||
Ok(archive) => archive,
|
||||
Err(e) => {
|
||||
// The archive was readable at scan time; whatever broke
|
||||
// it since costs its own photos, not the whole run.
|
||||
warn!(error = %e, photos = indices.len(), "cannot reopen a takeout archive");
|
||||
summary.failed += indices.len();
|
||||
for _ in &indices {
|
||||
job.step();
|
||||
report.step();
|
||||
}
|
||||
report.counts(summary);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
'archives: for (archive_index, indices) in by_archive {
|
||||
for index in indices {
|
||||
if self.import_should_stop(cancel) {
|
||||
stopped = true;
|
||||
break;
|
||||
}
|
||||
let mut archive = match open_archive(archives, archive_index) {
|
||||
Ok(archive) => archive,
|
||||
Err(e) => {
|
||||
// The archive was readable at scan time; whatever
|
||||
// broke it since costs its own photos, not the run.
|
||||
warn!(error = %e, photos = indices.len(), "cannot reopen a takeout archive");
|
||||
summary.failed += indices.len();
|
||||
for _ in &indices {
|
||||
job.step();
|
||||
report.step();
|
||||
}
|
||||
report.counts(summary);
|
||||
continue;
|
||||
}
|
||||
let main_uid = match planned[index].live {
|
||||
Some(LiveRole::Video(still)) => planned[still].uid.clone(),
|
||||
_ => None,
|
||||
};
|
||||
let photo = planned[index].photo.clone();
|
||||
job.detail(photo.name.clone());
|
||||
report.current(&photo.name);
|
||||
|
||||
for index in indices {
|
||||
for done in landed.try_iter() {
|
||||
self.record_upload(planned, done, summary, &mut favorites, job, report);
|
||||
}
|
||||
if self.import_should_stop(cancel) {
|
||||
stopped = true;
|
||||
break 'archives;
|
||||
}
|
||||
let item = &planned[index];
|
||||
let main_uid = match item.live {
|
||||
Some(LiveRole::Video(still)) => planned[still].uid.clone(),
|
||||
_ => None,
|
||||
};
|
||||
let tags = match item.live {
|
||||
Some(LiveRole::Still(tag)) => vec![tag],
|
||||
_ => Vec::new(),
|
||||
};
|
||||
let photo = item.photo.clone();
|
||||
job.detail(photo.name.clone());
|
||||
report.current(&photo.name);
|
||||
let uploaded =
|
||||
self.upload_takeout_photo(&mut archive, &planned[index], main_uid.clone());
|
||||
job.step();
|
||||
report.step();
|
||||
|
||||
// A thumbnail is made from a file, so a photo that can
|
||||
// have one is copied out of the archive and uploaded
|
||||
// from the copy by a worker. Without one, Proton's apps
|
||||
// show a blank tile until they make their own.
|
||||
let staged = can_make_thumbnail(&photo.name, photo.size)
|
||||
.then(|| self.stage_takeout_entry(&mut archive, &photo.entry))
|
||||
.and_then(|staged| {
|
||||
staged
|
||||
.inspect_err(|e| {
|
||||
warn!(error = %e,
|
||||
"copying a takeout photo out failed; uploading it without a thumbnail")
|
||||
})
|
||||
.ok()
|
||||
});
|
||||
match staged {
|
||||
Some(path) => {
|
||||
let upload = Upload {
|
||||
index,
|
||||
path,
|
||||
photo,
|
||||
tags,
|
||||
main_uid,
|
||||
};
|
||||
if let Err(std::sync::mpsc::SendError(upload)) = jobs.send(upload) {
|
||||
let _ = std::fs::remove_file(&upload.path);
|
||||
}
|
||||
match uploaded {
|
||||
Ok(uid) => {
|
||||
self.note_self_change(&uid);
|
||||
summary.uploaded += 1;
|
||||
summary.bytes += photo.size;
|
||||
if main_uid.is_some() {
|
||||
summary.live_photos += 1;
|
||||
}
|
||||
None => {
|
||||
let result = self.upload_takeout_photo(
|
||||
Source::Archive(&mut archive),
|
||||
&photo,
|
||||
tags,
|
||||
main_uid.clone(),
|
||||
);
|
||||
let done = Upload::streamed(index, photo, main_uid, result);
|
||||
self.record_upload(
|
||||
planned,
|
||||
done,
|
||||
summary,
|
||||
&mut favorites,
|
||||
job,
|
||||
report,
|
||||
);
|
||||
if photo.favorite {
|
||||
favorites.push(uid.clone());
|
||||
}
|
||||
planned[index].uid = Some(uid);
|
||||
if summary.uploaded.is_multiple_of(TIMELINE_REFRESH_EVERY) {
|
||||
self.spawn_timeline_refresh();
|
||||
}
|
||||
if summary.uploaded.is_multiple_of(CHECKPOINT_EVERY) {
|
||||
report.counts(summary);
|
||||
report.checkpoint();
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
summary.failed += 1;
|
||||
warn!(name = photo.name, error = %e, "takeout photo upload failed");
|
||||
}
|
||||
}
|
||||
report.counts(summary);
|
||||
}
|
||||
|
||||
drop(jobs);
|
||||
for done in landed.iter() {
|
||||
self.record_upload(planned, done, summary, &mut favorites, job, report);
|
||||
}
|
||||
});
|
||||
if stopped {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,55 +787,14 @@ impl Core {
|
||||
stopped
|
||||
}
|
||||
|
||||
/// Count one finished upload and file its uid in the plan.
|
||||
fn record_upload(
|
||||
&self,
|
||||
planned: &mut [Planned],
|
||||
done: Landed,
|
||||
summary: &mut ImportSummary,
|
||||
favorites: &mut Vec<NodeUid>,
|
||||
job: &crate::transfers::JobGuard,
|
||||
report: &Reporter,
|
||||
) {
|
||||
job.step();
|
||||
report.step();
|
||||
match done.result {
|
||||
Ok(uid) => {
|
||||
self.note_self_change(&uid);
|
||||
summary.uploaded += 1;
|
||||
summary.bytes += done.photo.size;
|
||||
if done.live {
|
||||
summary.live_photos += 1;
|
||||
}
|
||||
if done.photo.favorite {
|
||||
favorites.push(uid.clone());
|
||||
}
|
||||
planned[done.index].uid = Some(uid);
|
||||
if summary.uploaded.is_multiple_of(TIMELINE_REFRESH_EVERY) {
|
||||
self.spawn_timeline_refresh();
|
||||
}
|
||||
if summary.uploaded.is_multiple_of(CHECKPOINT_EVERY) {
|
||||
report.counts(summary);
|
||||
report.checkpoint();
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
summary.failed += 1;
|
||||
warn!(error = %e, "takeout photo upload failed");
|
||||
}
|
||||
}
|
||||
report.counts(summary);
|
||||
}
|
||||
|
||||
/// Upload one planned photo, from its staged copy or straight out of its
|
||||
/// open archive.
|
||||
/// Upload one planned photo out of its open archive.
|
||||
fn upload_takeout_photo(
|
||||
&self,
|
||||
source: Source<'_>,
|
||||
photo: &TakeoutPhoto,
|
||||
tags: Vec<PhotoTag>,
|
||||
archive: &mut zip::ZipArchive<std::io::BufReader<std::fs::File>>,
|
||||
item: &Planned,
|
||||
main_uid: Option<NodeUid>,
|
||||
) -> CoreResult<NodeUid> {
|
||||
let photo = &item.photo;
|
||||
let photos = self.photos();
|
||||
let guard = self.transfers.begin(
|
||||
photo.name.clone(),
|
||||
@@ -960,6 +802,10 @@ impl Core {
|
||||
TransferDirection::Upload,
|
||||
photo.size,
|
||||
);
|
||||
let tags = match item.live {
|
||||
Some(LiveRole::Still(tag)) => vec![tag],
|
||||
_ => Vec::new(),
|
||||
};
|
||||
let metadata = |capture_time: Option<i64>| PhotoUploadMetadata {
|
||||
capture_time,
|
||||
last_modification_time: capture_time.and_then(pdfs_core::timestamp::modification_time),
|
||||
@@ -974,8 +820,21 @@ impl Core {
|
||||
replace_existing_draft: true,
|
||||
};
|
||||
|
||||
match source {
|
||||
Source::Staged(path) => {
|
||||
// A thumbnail is made from a file, so a photo that can have one is
|
||||
// copied out of the archive first and uploaded from the copy. Without
|
||||
// one, Proton's apps show a blank tile until they make their own.
|
||||
let staged = can_make_thumbnail(&photo.name, photo.size)
|
||||
.then(|| self.stage_takeout_entry(archive, &photo.entry))
|
||||
.and_then(|staged| {
|
||||
staged
|
||||
.inspect_err(|e| {
|
||||
warn!(name = photo.name, error = %e,
|
||||
"copying a takeout photo out failed; uploading it without a thumbnail")
|
||||
})
|
||||
.ok()
|
||||
});
|
||||
let uploaded = match &staged {
|
||||
Some(path) => {
|
||||
let thumbnails = self.upload_thumbnails(path, &photo.name);
|
||||
// No sidecar date and none in the name: the photo's own EXIF,
|
||||
// then when Google received it, before Drive files it under
|
||||
@@ -1001,7 +860,7 @@ impl Core {
|
||||
.map_err(|e| CoreError::from_api(&e, "upload"))
|
||||
})
|
||||
}
|
||||
Source::Archive(archive) => read_entry(archive, &photo.entry, |reader| {
|
||||
None => read_entry(archive, &photo.entry, |reader| {
|
||||
let counting = CountingReader::new(reader, &guard);
|
||||
self.rt
|
||||
.block_on(photos.upload_photo_from(
|
||||
@@ -1016,7 +875,11 @@ impl Core {
|
||||
.map_err(|e| CoreError::from_api(&e, "upload"))
|
||||
})
|
||||
.and_then(|result| result),
|
||||
};
|
||||
if let Some(path) = staged {
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
uploaded
|
||||
}
|
||||
|
||||
/// Mark photos as favorites. A separate call: the upload seal takes
|
||||
|
||||
@@ -675,15 +675,45 @@ fn verify_in_browser(
|
||||
/// Sign out, after a confirmation: disable+stop the mount service (so the
|
||||
/// daemon isn't left running without credentials), forget the stored session,
|
||||
/// and drop back to the login page.
|
||||
///
|
||||
/// Changes still queued are named first: they stay staged here and are sent
|
||||
/// after the next sign-in, but until then they exist nowhere else.
|
||||
pub(crate) fn sign_out(ui: &Rc<Ui>) {
|
||||
let rx = spawn_request(ui.dirs.control_socket(), Request::Status);
|
||||
let ui = ui.clone();
|
||||
glib::spawn_future_local(async move {
|
||||
let queued = match rx.recv().await {
|
||||
Ok(Ok(Response::Status {
|
||||
pending_uploads,
|
||||
pending_changes,
|
||||
parked_uploads,
|
||||
..
|
||||
})) => pending_uploads + pending_changes + parked_uploads,
|
||||
_ => 0,
|
||||
};
|
||||
confirm_sign_out(&ui, queued);
|
||||
});
|
||||
}
|
||||
|
||||
fn confirm_sign_out(ui: &Rc<Ui>, queued: u64) {
|
||||
let Some(window) = ui_window(ui) else { return };
|
||||
let ui = ui.clone();
|
||||
let mut body = gettext(
|
||||
"Proton Drive will disconnect and stop syncing until you sign in again. Files already on this computer stay where they are.",
|
||||
);
|
||||
if queued > 0 {
|
||||
let warning = ngettext_f(
|
||||
"{n} change is not on Proton Drive yet. It stays on this computer and is sent after you sign in again.",
|
||||
"{n} changes are not on Proton Drive yet. They stay on this computer and are sent after you sign in again.",
|
||||
queued,
|
||||
&[],
|
||||
);
|
||||
body = format!("{warning}\n\n{body}");
|
||||
}
|
||||
confirm_destructive(
|
||||
&window,
|
||||
&gettext("Sign Out?"),
|
||||
&gettext(
|
||||
"Proton Drive will disconnect and stop syncing until you sign in again. Files already on this computer stay where they are.",
|
||||
),
|
||||
&body,
|
||||
&gettext("Sign Out"),
|
||||
move || {
|
||||
let galleries = ui.drive_galleries.borrow().upgrade();
|
||||
|
||||
+15
-2
@@ -74,7 +74,6 @@ original wording.
|
||||
| [B134](#b134--a-file-deleted-online-while-the-drain-checks-its-write-is-kept-as-a-conflict-copy) | A file deleted online while the drain checks its write is kept as a conflict copy | Only with `local_first` off |
|
||||
| [B91](#b91--the-daemon-hung-overnight-and-nothing-could-say-what-it-was-waiting-on) | The daemon hung overnight, and nothing could say what it was waiting on | The cause is not diagnosed; the daemon now reports where it is stuck and is restarted |
|
||||
| [B67](#b67--fresh-state-restore-can-silently-select-a-new-device-high-22) | Fresh-state restore can silently select a new device (HIGH-22) | An ambiguous device after a loss of local state is not asked about |
|
||||
| [B66](#b66--local-only-pending-data-is-not-protected-at-shutdown-high-21) | Local-only pending data is not protected at shutdown (HIGH-21) | No shutdown protection and no `pdfs sync flush` |
|
||||
| [B65](#b65--release-artifacts-lack-supply-chain-verification-med-11) | Release artifacts lack supply-chain verification (MED-11) | No SBOM, provenance or checksums |
|
||||
| [B15](#b15--an-empty-but-listed-folder-and-duplicated-folder-uids) | An empty-but-`listed` folder, and duplicated folder uids | Cause not attributed |
|
||||
| [B10](#b10--glib-critical-when-the-launcher-closes-over-an-in-flight-open) | GLib critical when the launcher closes over an in-flight open | |
|
||||
@@ -109,6 +108,7 @@ a live account since.
|
||||
|
||||
| Entry | Title |
|
||||
|---|---|
|
||||
| [B66](#b66--local-only-pending-data-is-not-protected-at-shutdown-high-21) | Local-only pending data is not protected at shutdown (HIGH-21) |
|
||||
| [B291](#b291--on-fedora-45s-oo7-every-saved-sign-in-is-lost-at-the-next-reboot) | On Fedora 45's oo7, every saved sign-in is lost at the next reboot |
|
||||
| [B289](#b289--the-takeout-import-mixes-in-other-services-and-drops-location-and-live-photos) | The Takeout import mixes in other services and drops location and live photos |
|
||||
| [B288](#b288--an-interrupted-takeout-import-reads-as-finished-and-one-error-ends-it) | An interrupted Takeout import reads as finished, and one error ends it |
|
||||
@@ -7475,7 +7475,7 @@ duplicates, renamed folders, multiple devices, and byte-identical restoration.
|
||||
|
||||
### B66 — Local-only pending data is not protected at shutdown (HIGH-21)
|
||||
|
||||
**Status:** Open — 1.0 data-safety/UX blocker
|
||||
**Status:** Fixed, unverified live
|
||||
**Found:** 2026-07-22, 1.0 recovery audit
|
||||
**Where:** shutdown, CLI/GUI status, logout/unregister workflows
|
||||
|
||||
@@ -7488,6 +7488,19 @@ and last errors, and protect destructive lifecycle actions. Test offline stop,
|
||||
logout, unregister, reboot, retry exhaustion, and drain. Credential removal must
|
||||
never delete staged bytes.
|
||||
|
||||
**Fix:** `crates/pdfs-fuse/src/inhibit.rs` takes a logind shutdown inhibitor
|
||||
(`systemd-inhibit --what=shutdown --mode=block`) while the queue holds changes
|
||||
the drain can send, and lets it go once they land. Parked transient files and
|
||||
changes that need the user are left out, so they never hold a power-off up for
|
||||
good. `pdfs sync flush` retries failed changes and waits for the queue, with
|
||||
its own exit codes for "needs you" and timeout. `pdfs logout` and the app's
|
||||
Sign Out dialog say how many changes are still queued and that they stay
|
||||
staged. Credential removal never touched `staging/`.
|
||||
|
||||
**Verified:** unit tests for which work holds the lock; `systemd-inhibit` in
|
||||
block mode taken by a user process on 2026-11-21. A power-off with a queued
|
||||
upload is still owed.
|
||||
|
||||
---
|
||||
|
||||
### B65 — Release artifacts lack supply-chain verification (MED-11)
|
||||
|
||||
+10
-5
@@ -11,13 +11,18 @@ scratch (user data in `staging/` and `recovery/` is never touched by this).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- `pdfs sync flush` waits until every queued change is on Proton Drive, retrying
|
||||
failed ones at once. It exits 3 when what is left needs you and 4 on `--timeout`.
|
||||
- While changes are queued that only this computer has, the daemon holds off a
|
||||
shutdown through logind, and desktops show "Sending N changes to Proton Drive" in
|
||||
their power-off dialog. Changes waiting on you never hold it up (B66).
|
||||
- Signing out, in the app or with `pdfs logout`, says how many changes are not on
|
||||
Proton Drive yet. They stay on this computer and are sent after the next sign-in.
|
||||
|
||||
### Changed
|
||||
|
||||
- A Google Photos import uploads two photos at once instead of one, while the next
|
||||
photo is read out of its archive. Live-photo videos still go after their stills, and
|
||||
cancelling still lets the uploads in flight finish.
|
||||
- proton-sdk 0.12.4: thumbnails need fewer requests to Proton (0.12.3), and the SDK
|
||||
can list photos that have no thumbnail (0.12.4).
|
||||
- Signing in runs through `proton_sdk::login` (proton-sdk 0.12.2), the sequence Proton
|
||||
Gallery and Proton Stream use too. The stored session, the lock/unlock choice for two-password
|
||||
accounts, the three mailbox-password tries and the messages stay as they were.
|
||||
|
||||
+2
-1
@@ -70,7 +70,7 @@ The script runs `pdfs` from `PATH` on every Tab, so it keeps working after an up
|
||||
| `pdfs login [-u EMAIL] [--remember]` | Sign in (password, then a 2FA code if the account has one) and store the session in the system keyring. Restarts the service if it is running. `--remember` keeps a two-password account unlocked across logins. |
|
||||
| `pdfs unlock [--remember]` | Enter the mailbox password of a two-password account, so the service can open your files. Needed once per login session, or once with `--remember`. |
|
||||
| `pdfs lock` | Forget the unlock held in memory; the account is locked again. |
|
||||
| `pdfs logout` | End the session on Proton and remove the stored session. |
|
||||
| `pdfs logout [--yes]` | End the session on Proton and remove the stored session. Asks first while changes are still queued; they stay on this computer and are sent after the next sign-in. |
|
||||
| `pdfs status` | Account, mount, queue and cache state. |
|
||||
| `pdfs quota` | Storage used across all Proton products. |
|
||||
| `pdfs locations` | Every local place the service occupies: the Proton Drive folder and each synced folder, with mode and state. |
|
||||
@@ -125,6 +125,7 @@ commands are for scripts and for cases where the mount is not available.
|
||||
| `pdfs sync ignore check PATH` | Say whether a file in a synced folder is synced, and which pattern decides. |
|
||||
| `pdfs sync limit [--up RATE] [--down RATE]` | Cap bandwidth, for example `500K` or `2M` per second. `0` removes a cap. Without options, prints the current caps. |
|
||||
| `pdfs sync queue` | List changes that have not reached Proton Drive yet. |
|
||||
| `pdfs sync flush [--timeout SECS]` | Retry failed changes now and wait until the queue is empty. Exits 0 when everything is on Proton Drive, 3 when what is left needs you (see `sync issues`), 4 on timeout. Says so while sync is paused or offline. |
|
||||
| `pdfs sync issues` | List queued changes Proton Drive refused or that keep failing, and what to do. |
|
||||
| `pdfs sync export ID DEST` | Save a copy of a queued upload's content. `DEST` may be a folder; an existing file is never overwritten. The upload stays queued. |
|
||||
| `pdfs sync discard ID [--yes]` | Drop a queued change and undo it here: a new file or folder goes, anything else goes back to what Proton Drive has. Content not exported first is lost. |
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ them along.
|
||||
|
||||
| Item | State | Notes |
|
||||
|---|---|---|
|
||||
| Protect queued changes at shutdown | Not started | A systemd inhibitor lock while `staging/` holds unsent data, a warning when signing out, and a `pdfs sync flush` that waits for the queue. Today the queue is visible in `pdfs sync queue`, the tray and **Sync → Overview**, but nothing stops a shutdown (B66) |
|
||||
| Protect queued changes at shutdown | Done, live check owed | The daemon holds a logind shutdown inhibitor while the queue holds changes it can send, signing out warns with the count, and `pdfs sync flush` waits for the queue (B66) |
|
||||
| Restore pins from the machine profile | Not started | `profile.json` records pins; `pdfs sync restore` does not apply them yet |
|
||||
| Profile backup health | Not started | A failed profile upload is a `WARN` in the log and nothing in the app (B68) |
|
||||
| Rotated credentials survive a keyring failure | Open | Report and retry keyring write failures, so a rotated single-use refresh token is not lost (B61) |
|
||||
@@ -63,7 +63,7 @@ them along.
|
||||
| Add someone else's photo to your album | Blocked | Needs `copyPhoto` in the SDK |
|
||||
| Photo name search | Not started | Photos search by date and filters only |
|
||||
| Automatic photo upload from a folder | Not started | |
|
||||
| Faster Google Photos import | Partly done | Two uploads run at once. Trash folders of locales missing from `TRASH_FOLDERS` import as photos |
|
||||
| Faster Google Photos import | Not started | Uploads run one at a time. Trash folders of locales missing from `TRASH_FOLDERS` import as photos |
|
||||
| More of a Google Photos export | Not started | `.tgz` exports and extracted folders; shared albums told apart from own ones; album descriptions and covers; photo descriptions |
|
||||
| Content-addressed block cache | Idea | Store blocks by hash to deduplicate identical content |
|
||||
|
||||
|
||||
+371
-360
File diff suppressed because it is too large.
Load diff
+371
-360
File diff suppressed because it is too large.
Load diff
+371
-360
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user