spacedriveapp/spacedrive · error
Failed to move entry: {}
Error message
Failed to move entry: {} What it means
DatabaseStorage::move_entry failed while relocating an entry from old_path to new_path during change detection. Moves touch the entry row, its path materialization, and the entry_closure hierarchy, so failures commonly come from a unique-path conflict at the destination, a stale parent id from entry_id_cache, or closure-table rebuild errors.
Source
Thrown at core/src/ops/indexing/change_detection/persistent.rs:311
} else if let Ok(Some(parent_id)) =
DatabaseStorage::resolve_parent_id(&self.db, new_parent_path).await
{
state
.entry_id_cache
.insert(new_parent_path.to_path_buf(), parent_id);
self.entry_id_cache
.insert(new_parent_path.to_path_buf(), parent_id);
}
DatabaseStorage::move_entry(
&mut state,
&self.db,
entry.id,
old_path,
new_path,
new_parent_path,
)
.await
.map_err(|e| anyhow::anyhow!("Failed to move entry: {}", e))?;
self.entry_id_cache.remove(old_path);
self.entry_id_cache.insert(new_path.to_path_buf(), entry.id);
Ok(())
}
async fn delete(&mut self, entry: &EntryRef) -> Result<()> {
let mut to_delete_ids: Vec<i32> = vec![entry.id];
if let Ok(rows) = entities::entry_closure::Entity::find()
.filter(entities::entry_closure::Column::AncestorId.eq(entry.id))
.all(&self.db)
.await
{
to_delete_ids.extend(rows.into_iter().map(|r| r.descendant_id));
}
View on GitHub (pinned to 6dfeccf211)
Solutions
- Check the wrapped error for unique-path conflicts and resolve by re-scanning the destination directory
- Invalidate entry_id_cache for the parent before the move if the parent was recently created/moved
- Verify entry_closure integrity for the subtree when moves repeatedly fail
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check the destination is free before initiating a move
if self.find_by_path(new_path).await?.is_some() {
// destination occupied: scan/resolution needed before moving
} Try / catch
if let Err(e) = DatabaseStorage::move_entry(&mut state, &self.db, entry.id, old_path, new_path, new_parent_path).await {
if e.to_string().contains("UNIQUE") {
// destination conflict: re-scan destination dir and drop stale cache
self.entry_id_cache.remove(new_parent_path);
}
return Err(anyhow::anyhow!("Failed to move entry: {}", e));
} Prevention
- Order watcher move events (process parents before children, a→b before b→c)
- Invalidate cached parent ids whenever the parent itself was moved
- Periodically verify entry_closure consistency for heavily-renamed trees
When it happens
Trigger: Destination path already occupied by another entry; parent directory row deleted concurrently; closure table in inconsistent state from an earlier crashed move; DB lock contention.
Common situations: Rapid rename chains (a → b → c) processed out of order by watcher workers; moving entries into directories that were themselves just moved; two locations overlapping on the same physical paths.
Related errors
- Library not found: {}
- Location not found: {}
- Location {} has no root entry
- Location {} has no volume_id - volume must be detected befor
- Entry {} not found after ID lookup
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/8828ce293c0be6f5.
Report an issue: GitHub.