mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Fixup for deleting items
First, when checking for existence of a file, deleted items are not conisdered. The working with fulltext search has been changed: deleted items are removed from fulltext index and are re-added when they are restored. The fulltext index currently doesn't hold the item state and it would mean much more work to introduce it into the index (or, worse, to reprocess the results from the index). Thus, deleted items can only be searched using database queries. It is probably a very rare use case when fulltext search should be applied to deleted items. They have been deleted for a reason and the most likely case is that they are simply removed. Refs: #347
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
package docspell.store.queries
|
||||
|
||||
import cats.data.OptionT
|
||||
import cats.data.{NonEmptyList => Nel}
|
||||
import cats.effect.Sync
|
||||
import cats.implicits._
|
||||
import fs2.Stream
|
||||
@ -174,6 +175,7 @@ object QAttachment {
|
||||
)
|
||||
def allAttachmentMetaAndName(
|
||||
coll: Option[Ident],
|
||||
itemIds: Option[Nel[Ident]],
|
||||
chunkSize: Int
|
||||
): Stream[ConnectionIO, ContentAndName] =
|
||||
Select(
|
||||
@ -190,8 +192,11 @@ object QAttachment {
|
||||
.innerJoin(am, am.id === a.id)
|
||||
.innerJoin(item, item.id === a.itemId)
|
||||
.innerJoin(c, c.id === item.cid)
|
||||
).where(coll.map(cid => item.cid === cid))
|
||||
.build
|
||||
).where(
|
||||
item.state.in(ItemState.validStates) &&?
|
||||
itemIds.map(ids => item.id.in(ids)) &&?
|
||||
coll.map(cid => item.cid === cid)
|
||||
).build
|
||||
.query[ContentAndName]
|
||||
.streamWithChunkSize(chunkSize)
|
||||
|
||||
|
@ -502,6 +502,7 @@ object QItem {
|
||||
.leftJoin(m3, m3.id === r.fileId),
|
||||
where(
|
||||
i.cid === collective &&
|
||||
i.state.in(ItemState.validStates) &&
|
||||
Condition.Or(fms.map(m => m.checksum === checksum)) &&?
|
||||
Nel
|
||||
.fromList(excludeFileMeta.toList)
|
||||
@ -519,6 +520,7 @@ object QItem {
|
||||
)
|
||||
def allNameAndNotes(
|
||||
coll: Option[Ident],
|
||||
itemIds: Option[Nel[Ident]],
|
||||
chunkSize: Int
|
||||
): Stream[ConnectionIO, NameAndNotes] = {
|
||||
val i = RItem.as("i")
|
||||
@ -526,8 +528,11 @@ object QItem {
|
||||
Select(
|
||||
select(i.id, i.cid, i.folder, i.name, i.notes),
|
||||
from(i)
|
||||
).where(coll.map(cid => i.cid === cid))
|
||||
.build
|
||||
).where(
|
||||
i.state.in(ItemState.validStates) &&?
|
||||
itemIds.map(ids => i.id.in(ids)) &&?
|
||||
coll.map(cid => i.cid === cid)
|
||||
).build
|
||||
.query[NameAndNotes]
|
||||
.streamWithChunkSize(chunkSize)
|
||||
}
|
||||
|
Reference in New Issue
Block a user