mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-13 01:27:03 +01:00
Merge pull request #79 from narrrl/chore/sdk-0.11.0
build(sdk): bump to 0.11.0
This commit is contained in:
12 files changed
+133
-14
No files matched your search
@@ -12,6 +12,7 @@ description = "Core auth/session/config for the Proton Drive Linux client"
|
||||
[dependencies]
|
||||
proton-sdk.workspace = true
|
||||
proton-drive-rs.workspace = true
|
||||
chrono.workspace = true
|
||||
tokio.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
@@ -29,6 +29,7 @@ pub mod similar;
|
||||
pub mod syncignore;
|
||||
pub mod syncroot;
|
||||
pub mod takeout;
|
||||
pub mod timestamp;
|
||||
pub mod tray;
|
||||
pub mod update;
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//! Convert the client's stored epoch seconds at the SDK boundary.
|
||||
|
||||
use proton_drive_rs::ModificationTime;
|
||||
|
||||
/// A UTC modification time, or `None` when outside the SDK's supported range.
|
||||
pub fn modification_time(seconds: i64) -> Option<ModificationTime> {
|
||||
chrono::DateTime::from_timestamp(seconds, 0).map(|time| time.fixed_offset())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn epoch_seconds_preserve_the_instant_including_before_1970() {
|
||||
for seconds in [-1, 0, 1_709_208_000, 1_782_482_460] {
|
||||
let time = modification_time(seconds).unwrap();
|
||||
assert_eq!(time.timestamp(), seconds);
|
||||
assert_eq!(time.offset().local_minus_utc(), 0);
|
||||
assert_eq!(time.timestamp_subsec_nanos(), 0);
|
||||
}
|
||||
assert_eq!(
|
||||
modification_time(-1).unwrap().to_rfc3339(),
|
||||
"1969-12-31T23:59:59+00:00"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn out_of_range_seconds_omit_the_timestamp() {
|
||||
assert!(modification_time(i64::MIN).is_none());
|
||||
assert!(modification_time(i64::MAX).is_none());
|
||||
}
|
||||
}
|
||||
@@ -939,6 +939,8 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
||||
});
|
||||
let metadata = proton_drive_rs::PhotoUploadMetadata {
|
||||
capture_time,
|
||||
last_modification_time: capture_time
|
||||
.and_then(pdfs_core::timestamp::modification_time),
|
||||
..Default::default()
|
||||
};
|
||||
let thumbnails = core.upload_thumbnails(Path::new(&source_path), &name);
|
||||
|
||||
@@ -352,7 +352,13 @@ impl DriveApi for ProtonDriveClient {
|
||||
name: &str,
|
||||
last_modification_time: Option<i64>,
|
||||
) -> Result<NodeUid> {
|
||||
ProtonDriveClient::create_folder(self, parent_uid, name, last_modification_time).await
|
||||
ProtonDriveClient::create_folder(
|
||||
self,
|
||||
parent_uid,
|
||||
name,
|
||||
last_modification_time.and_then(pdfs_core::timestamp::modification_time),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn upload_file(
|
||||
@@ -384,7 +390,7 @@ impl DriveApi for ProtonDriveClient {
|
||||
reader,
|
||||
intended_size,
|
||||
thumbnails,
|
||||
last_modification_time,
|
||||
last_modification_time.and_then(pdfs_core::timestamp::modification_time),
|
||||
aead,
|
||||
)
|
||||
.await
|
||||
@@ -409,7 +415,7 @@ impl DriveApi for ProtonDriveClient {
|
||||
reader,
|
||||
intended_size,
|
||||
thumbnails,
|
||||
last_modification_time,
|
||||
last_modification_time.and_then(pdfs_core::timestamp::modification_time),
|
||||
aead,
|
||||
)
|
||||
.await
|
||||
@@ -429,7 +435,7 @@ impl DriveApi for ProtonDriveClient {
|
||||
reader,
|
||||
intended_size,
|
||||
thumbnails,
|
||||
last_modification_time,
|
||||
last_modification_time.and_then(pdfs_core::timestamp::modification_time),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -200,6 +200,7 @@ impl Core {
|
||||
let reader = CountingReader::new(std::io::BufReader::new(file), &guard);
|
||||
let metadata = PhotoUploadMetadata {
|
||||
capture_time: Some(candidate.wanted),
|
||||
last_modification_time: pdfs_core::timestamp::modification_time(candidate.wanted),
|
||||
..Default::default()
|
||||
};
|
||||
let uploaded = self.rt.block_on(photos.upload_photo_from(
|
||||
|
||||
@@ -344,6 +344,9 @@ impl Core {
|
||||
);
|
||||
let metadata = PhotoUploadMetadata {
|
||||
capture_time: photo.capture_time,
|
||||
last_modification_time: photo
|
||||
.capture_time
|
||||
.and_then(pdfs_core::timestamp::modification_time),
|
||||
..Default::default()
|
||||
};
|
||||
// A thumbnail is made from a file, so a photo that can have one
|
||||
@@ -365,10 +368,13 @@ impl Core {
|
||||
let thumbnails = self.upload_thumbnails(path, &photo.name);
|
||||
// No sidecar and no date in the name: the photo's own
|
||||
// EXIF, before Drive files it under today.
|
||||
let capture_time = metadata
|
||||
.capture_time
|
||||
.or_else(|| pdfs_core::exiftime::capture_time_of(path));
|
||||
let metadata = PhotoUploadMetadata {
|
||||
capture_time: metadata
|
||||
.capture_time
|
||||
.or_else(|| pdfs_core::exiftime::capture_time_of(path)),
|
||||
capture_time,
|
||||
last_modification_time: capture_time
|
||||
.and_then(pdfs_core::timestamp::modification_time),
|
||||
..metadata
|
||||
};
|
||||
std::fs::File::open(path)
|
||||
|
||||
Reference in new issue
Block a user