[ENG-884] Update file_path metadata (#1077)

* Partitioned paths to be updated on walker

* Updating file_paths in indexer

* Properly tracking modified date on renames

---------

Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com>
This commit is contained in:
Ericson "Fogo" SoaresandVítor Vasconcellos authored and GitHub committed 2023-07-11 15:14:11 +00:00
1 parent 121b5b4bfe
commit 7cd00dab49
13 files changed
+441 -118

No files matched your search

+9 -18
View File
@@ -14,7 +14,6 @@ use std::path::PathBuf;
use rspc::{self, alpha::AlphaRouter, ErrorCode};
use serde::{Deserialize, Serialize};
use specta::Type;
use tracing::info;
use super::{utils::library, Ctx, R};
@@ -141,28 +140,20 @@ pub(crate) fn mount() -> AlphaRouter<Ctx> {
reidentify_objects,
}| async move {
if reidentify_objects {
let object_ids = library
library
.db
.file_path()
.find_many(vec![
file_path::location_id::equals(Some(location_id)),
file_path::object_id::not(None),
])
.select(file_path::select!({ object_id }))
.exec()
.await?
.into_iter()
.filter_map(|file_path| file_path.object_id)
.collect::<Vec<_>>();
let count = library
.db
.object()
.delete_many(vec![object::id::in_vec(object_ids)])
.update_many(
vec![
file_path::location_id::equals(Some(location_id)),
file_path::object_id::not(None),
],
vec![file_path::object::disconnect()],
)
.exec()
.await?;
info!("Deleted {count} objects, to be reidentified");
library.orphan_remover.invoke().await;
}
// rescan location