IX7: a file kept only in iCloud is left out of the fast pass and counted, not read: reading a dataless file (SF_DATALESS, iCloud Drive with Optimise Mac Storage) downloads its original. On this Mac all 3,849 iCloud Drive files were cloud-only, 2,245 of them pictures and videos, which switching iCloud Drive on in the Index page would have pulled down. walk.rs cloud_only reads the flag from the stat it already has; Listed and Progress say how many (cloud), the listing's last event carries it, and the CLI says "N only in iCloud, left out". Checked on a folder of three cloud-only pictures and two local ones: two searchable, three left out, all three still dataless after. The Quick Look path that indexes them without a download stays IX7's plan

This commit is contained in:
shinyobjectz committed 2026-11-15 00:14:03 -08:00
1 parent 13886ff3c5
commit 937387c3db
4 files changed
+44 -12

No files matched your search

+4
View File
@@ -84,6 +84,10 @@ Feature: Index: every picture and video you have, searchable in minutes (0.1.5)
Then iCloud Drive is a folder source (~/Library/Mobile Documents/com~apple~CloudDocs); a file kept only in iCloud
is indexed from its Quick Look thumbnail (QLThumbnailGenerator) without downloading it, marked "in iCloud", and
downloaded only when opened
Status 11-15: until the Quick Look path, a file kept only in iCloud (SF_DATALESS) is left out and counted
(walk.rs cloud_only; Progress.cloud, and the CLI says "N only in iCloud, left out"). Reading one downloads its
original: on this Mac all 3,849 iCloud Drive files were cloud-only, 2,245 of them pictures and videos, and
switching iCloud Drive on would have pulled every one down
Scenario: IX8. Google Drive
Then through the Drive connection (raea-api src/connect; Drive is live since 11-11), raea-api lists the Drive's
+3
View File
@@ -97,6 +97,9 @@ fn add(f: &Flags, home: &std::path::Path) -> Result<()> {
}
if !f.json {
println!("{}: {} found ({} new), {} searchable, {} failed; {:.0} a second over {:.1} s", root.display(), l.found, l.added, p.done, p.failed, p.per_sec, p.seconds);
if l.cloud > 0 {
println!(" {} only in iCloud, left out: reading them would download each original", l.cloud);
}
}
}
#[cfg(not(target_vendor = "apple"))]
+14 -8
View File
@@ -51,6 +51,9 @@ pub struct Progress {
pub seconds: f64,
/// the items finished since the last report, newest last, for the wall of thumbnails
pub newest: Vec<i64>,
/// pictures and videos the listing left out because their bytes are only in iCloud (walk.rs cloud_only): reading
/// one would download its original
pub cloud: u64,
pub stage: &'static str,
}
@@ -99,31 +102,31 @@ pub struct Listed {
pub added: u64,
/// items whose file changed since the last listing: their old rows are gone
pub changed: u64,
/// items left out as only in iCloud (Progress::cloud)
pub cloud: u64,
}
/// Lists a folder or a drive into the index: new files added, changed ones put back in line
pub fn list_folder(store: &mut Store, root: &Path, on: &mut dyn FnMut(&Progress)) -> Result<Listed> {
let label = root.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_else(|| root.display().to_string());
let each = |f: &mut dyn FnMut(Vec<Found>)| {
walk::walk(root, 2000, f);
Ok(())
};
let each = |f: &mut dyn FnMut(Vec<Found>)| Ok(walk::walk(root, 2000, f).1);
list_source(store, ("folder", &root.to_string_lossy(), &label), each, on)
}
/// Lists Apple Photos into the index (photos.rs): its root is `photos:`, each item an asset
#[cfg(target_vendor = "apple")]
pub fn list_photos(store: &mut Store, on: &mut dyn FnMut(&Progress)) -> Result<Listed> {
list_source(store, ("photos", PHOTOS, "Apple Photos"), |f| photos::list(2000, f).map_err(anyhow::Error::msg), on)
list_source(store, ("photos", PHOTOS, "Apple Photos"), |f| photos::list(2000, f).map(|_| 0).map_err(anyhow::Error::msg), on)
}
/// Lists a source (its kind, root and label) as `each` hands its items over a batch at a time
fn list_source(store: &mut Store, (kind, root, label): (&str, &str, &str), each: impl FnOnce(&mut dyn FnMut(Vec<Found>)) -> Result<()>, on: &mut dyn FnMut(&Progress)) -> Result<Listed> {
/// Lists a source (its kind, root and label) as `each` hands its items over a batch at a time and then says how many
/// it left out as only in iCloud
fn list_source(store: &mut Store, (kind, root, label): (&str, &str, &str), each: impl FnOnce(&mut dyn FnMut(Vec<Found>)) -> Result<u64>, on: &mut dyn FnMut(&Progress)) -> Result<Listed> {
let source = store.source(kind, root, label)?;
let started = Instant::now();
let mut l = Listed { source: source.clone(), ..Listed::default() };
let mut err = None;
each(&mut |batch| {
l.cloud = each(&mut |batch| {
l.found += batch.len() as u64;
match store.list(&source, &batch) {
Ok((a, c)) => {
@@ -139,6 +142,9 @@ fn list_source(store: &mut Store, (kind, root, label): (&str, &str, &str), each:
if let Some(e) = err {
return Err(e);
}
if l.cloud > 0 {
on(&Progress { source: source.clone(), found: l.found, cloud: l.cloud, stage: "listing", seconds: started.elapsed().as_secs_f64(), ..Progress::default() });
}
Ok(l)
}
+23 -4
View File
@@ -37,10 +37,25 @@ fn skipped(name: &str, depth: usize) -> bool {
SKIP.contains(&name) && (name != "Library" || depth <= 1)
}
/// Every picture and video under `root`, `on` called with each batch of `every` as they're found
pub fn walk(root: &Path, every: usize, on: &mut dyn FnMut(Vec<Found>)) -> u64 {
/// Whether a file's bytes are only in the cloud (iCloud Drive with Optimise Mac Storage, or another File Provider):
/// it lists at its full size, but reading it downloads the original, so the fast pass leaves it until it's on this Mac
#[cfg(target_os = "macos")]
fn cloud_only(m: &std::fs::Metadata) -> bool {
use std::os::macos::fs::MetadataExt;
const SF_DATALESS: u32 = 0x4000_0000;
m.st_flags() & SF_DATALESS != 0
}
#[cfg(not(target_os = "macos"))]
fn cloud_only(_: &std::fs::Metadata) -> bool {
false
}
/// Every picture and video under `root`, `on` called with each batch of `every` as they're found; says how many it
/// found and how many it left out as only in the cloud (cloud_only)
pub fn walk(root: &Path, every: usize, on: &mut dyn FnMut(Vec<Found>)) -> (u64, u64) {
let mut batch = Vec::with_capacity(every);
let mut n = 0u64;
let (mut n, mut cloud) = (0u64, 0u64);
let it = walkdir::WalkDir::new(root).follow_links(false).into_iter().filter_entry(|e| e.depth() == 0 || !skipped(&e.file_name().to_string_lossy(), e.depth()));
for e in it.flatten() {
// a link to a file counts as the file (a link to a folder isn't followed: no loops)
@@ -56,6 +71,10 @@ pub fn walk(root: &Path, every: usize, on: &mut dyn FnMut(Vec<Found>)) -> u64 {
if m.len() < 1024 {
continue;
}
if cloud_only(&m) {
cloud += 1;
continue;
}
let secs = |t: std::io::Result<std::time::SystemTime>| t.ok().and_then(|t| t.duration_since(UNIX_EPOCH).ok()).map(|d| d.as_secs() as i64);
let mtime = secs(m.modified()).unwrap_or(0);
batch.push(Found {
@@ -75,5 +94,5 @@ pub fn walk(root: &Path, every: usize, on: &mut dyn FnMut(Vec<Found>)) -> u64 {
if !batch.is_empty() {
on(batch);
}
n
(n, cloud)
}