WebDAV COPY/MOVE tests

This commit is contained in:
mdecimus
2025-05-01 16:35:07 +02:00
parent 91944162d9
commit 5416e35d4d
28 changed files with 1600 additions and 363 deletions

View File

@@ -7,7 +7,7 @@
use common::storage::index::{
IndexItem, IndexValue, IndexableAndSerializableObject, IndexableObject,
};
use jmap_proto::types::{collection::Collection, value::AclGrant};
use jmap_proto::types::value::AclGrant;
use store::{SerializeInfallible, write::key::KeySerializer};
use crate::{IDX_NAME, IDX_TIME, IDX_UID};
@@ -123,10 +123,6 @@ impl IndexableObject for CalendarEvent {
+ self.size,
},
IndexValue::LogChild { prefix: None },
IndexValue::LogParent {
collection: Collection::Calendar.into(),
ids: self.names.iter().map(|n| n.parent_id).collect(),
},
]
.into_iter()
}
@@ -167,10 +163,6 @@ impl IndexableObject for &ArchivedCalendarEvent {
+ self.size,
},
IndexValue::LogChild { prefix: None },
IndexValue::LogParent {
collection: Collection::Calendar.into(),
ids: self.names.iter().map(|n| n.parent_id.to_native()).collect(),
},
]
.into_iter()
}

View File

@@ -7,7 +7,7 @@
use common::storage::index::{
IndexItem, IndexValue, IndexableAndSerializableObject, IndexableObject,
};
use jmap_proto::types::{collection::Collection, value::AclGrant};
use jmap_proto::types::value::AclGrant;
use store::SerializeInfallible;
use crate::{IDX_NAME, IDX_UID};
@@ -89,10 +89,6 @@ impl IndexableObject for ContactCard {
+ self.size,
},
IndexValue::LogChild { prefix: None },
IndexValue::LogParent {
collection: Collection::AddressBook.into(),
ids: self.names.iter().map(|n| n.parent_id).collect(),
},
]
.into_iter()
}
@@ -120,10 +116,6 @@ impl IndexableObject for &ArchivedContactCard {
+ self.size,
},
IndexValue::LogChild { prefix: None },
IndexValue::LogParent {
collection: Collection::AddressBook.into(),
ids: self.names.iter().map(|n| n.parent_id.to_native()).collect(),
},
]
.into_iter()
}

View File

@@ -60,11 +60,21 @@ impl DavHierarchy for Server {
account_id: u32,
collection: Collection,
) -> trc::Result<Arc<DavResources>> {
let change_id = self
let is_files = collection == Collection::FileNode;
let mut change_id = self
.store()
.get_last_change_id(account_id, collection)
.await
.caused_by(trc::location!())?;
if !is_files {
let child_change_id = self
.store()
.get_last_change_id(account_id, collection.child_collection().unwrap())
.await
.caused_by(trc::location!())?;
change_id = change_id.max(child_change_id);
}
let resource_id = DavResourceId {
account_id,
collection: collection.into(),
@@ -78,28 +88,26 @@ impl DavHierarchy for Server {
{
Ok(files)
} else {
let mut files = match collection {
Collection::Calendar | Collection::AddressBook => {
let files = build_hierarchy(self, account_id, collection).await?;
if files.paths.is_empty() {
match collection {
Collection::Calendar => {
self.create_default_calendar(access_token, account_id)
.await?
}
Collection::AddressBook => {
self.create_default_addressbook(access_token, account_id)
.await?
}
_ => unreachable!(),
let mut files = if !is_files {
let files = build_hierarchy(self, account_id, collection).await?;
if files.paths.is_empty() {
match collection {
Collection::Calendar => {
self.create_default_calendar(access_token, account_id)
.await?
}
build_hierarchy(self, account_id, collection).await?
} else {
files
Collection::AddressBook => {
self.create_default_addressbook(access_token, account_id)
.await?
}
_ => unreachable!(),
}
build_hierarchy(self, account_id, collection).await?
} else {
files
}
Collection::FileNode => build_file_hierarchy(self, account_id).await?,
_ => unreachable!(),
} else {
build_file_hierarchy(self, account_id).await?
};
files.modseq = change_id;