spacedriveapp/spacedrive · error

Failed to add entry to ephemeral index: {}

Error message

Failed to add entry to ephemeral index: {}

What it means

The ephemeral index writer's add_entry_internal locks the in-memory index and calls index.add_entry; any failure there (duplicate path already interned, arena allocation error, invalid name/parent combination) is wrapped with this message. The write lock is held during the call, so this is a structural index error rather than an I/O error.

Source

Thrown at core/src/ops/indexing/ephemeral/writer.rs:71

		}
	}

	fn next_id(&self) -> i32 {
		self.next_id.fetch_add(1, Ordering::SeqCst)
	}

	/// Core write operation shared by both watcher and indexer pipelines.
	async fn add_entry_internal(
		&self,
		path: &Path,
		uuid: Uuid,
		metadata: EntryMetadata,
	) -> Result<(i32, Option<crate::domain::ContentKind>)> {
		let content_kind = {
			let mut index = self.index.write().await;
			index
				.add_entry(path.to_path_buf(), uuid, metadata.clone())
				.map_err(|e| anyhow::anyhow!("Failed to add entry to ephemeral index: {}", e))?
		};

		let entry_id = self.next_id();
		Ok((entry_id, content_kind))
	}

	async fn emit_resource_changed(
		&self,
		uuid: Uuid,
		path: &Path,
		metadata: &EntryMetadata,
		content_kind: crate::domain::ContentKind,
	) {
		use crate::device::get_current_device_slug;
		use crate::domain::addressing::SdPath;
		use crate::domain::file::File;
		use crate::infra::event::{Event, ResourceMetadata};

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Read the wrapped inner error: 'already present' means the event was duplicated and can be treated as an update instead
  2. Deduplicate watcher events before they reach the writer
  3. Ensure parent directories are added before children (ordered walks)
Defensive patterns

Strategy: try-catch

Try / catch

match index.add_entry(path.to_path_buf(), uuid, metadata.clone()) {
    Ok(kind) => kind,
    Err(e) if e.to_string().contains("already") => {
        // duplicate event: fall through to update semantics
        index.update_entry(path, metadata)?
    }
    Err(e) => return Err(anyhow::anyhow!("Failed to add entry to ephemeral index: {}", e)),
}

Prevention

When it happens

Trigger: Watcher and indexer pipelines inserting the same path concurrently in a way that double-adds; adding an entry whose parent name is not yet interned; arena capacity or allocation limits hit on very large ephemeral scans.

Common situations: Duplicate filesystem events for one create; ephemeral cache used across restarts with stale interning state; extremely large directories exhausting arena capacity.

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/388fb9729d314425. Report an issue: GitHub.