Reformat with scalafmt 3.0.0

This commit is contained in:
Scala Steward
2021-08-19 08:50:30 +02:00
parent 5a2a0295ef
commit e4fecefaea
127 changed files with 558 additions and 658 deletions

View File

@ -41,6 +41,6 @@ private[auth] object TokenUtil {
def constTimeEq(s1: String, s2: String): Boolean =
s1.zip(s2)
.foldLeft(true)({ case (r, (c1, c2)) => r & c1 == c2 }) & s1.length == s2.length
.foldLeft(true) { case (r, (c1, c2)) => r & c1 == c2 } & s1.length == s2.length
}

View File

@ -18,8 +18,8 @@ import docspell.store.queries.QItem
trait CreateIndex[F[_]] {
/** Low-level function to re-index data. It is not submitted as a job,
* but invoked on the current machine.
/** Low-level function to re-index data. It is not submitted as a job, but invoked on
* the current machine.
*/
def reIndexData(
logger: Logger[F],

View File

@ -84,9 +84,9 @@ object Merge {
nextPos <- store.transact(RAttachment.nextPosition(target))
attachs <- store.transact(items.tail.traverse(id => RAttachment.findByItem(id)))
attachFlat = attachs.flatMap(_.toList)
n <- attachFlat.zipWithIndex.traverse({ case (a, idx) =>
n <- attachFlat.zipWithIndex.traverse { case (a, idx) =>
store.transact(RAttachment.updateItemId(a.id, target, nextPos + idx))
})
}
} yield n.sum
}

View File

@ -63,8 +63,8 @@ trait OCollective[F[_]] {
def startEmptyTrash(args: EmptyTrashArgs): F[Unit]
/** Submits a task that (re)generates the preview images for all
* attachments of the given collective.
/** Submits a task that (re)generates the preview images for all attachments of the
* given collective.
*/
def generatePreviews(
storeMode: MakePreviewArgs.StoreMode,
@ -180,7 +180,7 @@ object OCollective {
id <- Ident.randomId[F]
settings = sett.emptyTrash.getOrElse(EmptyTrash.default)
args = EmptyTrashArgs(coll, settings.minAge)
ut = UserTask(id, EmptyTrashArgs.taskName, true, settings.schedule, None, args)
ut = UserTask(id, EmptyTrashArgs.taskName, true, settings.schedule, None, args)
_ <- uts.updateOneTask(UserTaskScope(coll), args.makeSubject.some, ut)
_ <- joex.notifyAllNodes
} yield ()

View File

@ -23,9 +23,8 @@ trait OFolder[F[_]] {
def findById(id: Ident, account: AccountId): F[Option[OFolder.FolderDetail]]
/** Adds a new folder. If `login` is non-empty, the `folder.user`
* property is ignored and the user-id is determined by the given
* login name.
/** Adds a new folder. If `login` is non-empty, the `folder.user` property is ignored
* and the user-id is determined by the given login name.
*/
def add(folder: RFolder, login: Option[Ident]): F[AddResult]

View File

@ -49,13 +49,12 @@ trait OFulltext[F[_]] {
def findIndexOnlySummary(account: AccountId, fts: OFulltext.FtsInput): F[SearchSummary]
def findItemsSummary(q: Query, fts: OFulltext.FtsInput): F[SearchSummary]
/** Clears the full-text index completely and launches a task that
* indexes all data.
/** Clears the full-text index completely and launches a task that indexes all data.
*/
def reindexAll: F[Unit]
/** Clears the full-text index for the given collective and starts a
* task indexing all their data.
/** Clears the full-text index for the given collective and starts a task indexing all
* their data.
*/
def reindexCollective(account: AccountId): F[Unit]
}
@ -125,7 +124,7 @@ object OFulltext {
FtsQuery.HighlightSetting(ftsQ.highlightPre, ftsQ.highlightPost)
)
for {
_ <- logger.ftrace(s"Find index only: ${ftsQ.query}/${batch}")
_ <- logger.ftrace(s"Find index only: ${ftsQ.query}/$batch")
folders <- store.transact(QFolder.getMemberFolders(account))
ftsR <- fts.search(fq.withFolders(folders))
ftsItems = ftsR.results.groupBy(_.itemId)
@ -154,7 +153,7 @@ object OFulltext {
res =
itemsWithTags
.collect(convertFtsData(ftsR, ftsItems))
.map({ case (li, fd) => FtsItemWithTags(li, fd) })
.map { case (li, fd) => FtsItemWithTags(li, fd) }
} yield res
}
@ -203,7 +202,7 @@ object OFulltext {
)
.drop(batch.offset.toLong)
.take(batch.limit.toLong)
.map({ case (li, fd) => FtsItem(li, fd) })
.map { case (li, fd) => FtsItem(li, fd) }
.compile
.toVector
@ -221,7 +220,7 @@ object OFulltext {
)
.drop(batch.offset.toLong)
.take(batch.limit.toLong)
.map({ case (li, fd) => FtsItemWithTags(li, fd) })
.map { case (li, fd) => FtsItemWithTags(li, fd) }
.compile
.toVector

View File

@ -28,9 +28,8 @@ trait OItem[F[_]] {
/** Sets the given tags (removing all existing ones). */
def setTags(item: Ident, tagIds: List[String], collective: Ident): F[UpdateResult]
/** Sets tags for multiple items. The tags of the items will be
* replaced with the given ones. Same as `setTags` but for multiple
* items.
/** Sets tags for multiple items. The tags of the items will be replaced with the given
* ones. Same as `setTags` but for multiple items.
*/
def setTagsMultipleItems(
items: NonEmptyList[Ident],
@ -41,8 +40,8 @@ trait OItem[F[_]] {
/** Create a new tag and add it to the item. */
def addNewTag(item: Ident, tag: RTag): F[AddResult]
/** Apply all tags to the given item. Tags must exist, but can be IDs
* or names. Existing tags on the item are left unchanged.
/** Apply all tags to the given item. Tags must exist, but can be IDs or names. Existing
* tags on the item are left unchanged.
*/
def linkTags(item: Ident, tags: List[String], collective: Ident): F[UpdateResult]
@ -163,10 +162,9 @@ trait OItem[F[_]] {
collective: Ident
): F[UpdateResult]
/** Submits the item for re-processing. The list of attachment ids can
* be used to only re-process a subset of the item's attachments.
* If this list is empty, all attachments are reprocessed. This
* call only submits the job into the queue.
/** Submits the item for re-processing. The list of attachment ids can be used to only
* re-process a subset of the item's attachments. If this list is empty, all
* attachments are reprocessed. This call only submits the job into the queue.
*/
def reprocess(
item: Ident,
@ -181,9 +179,8 @@ trait OItem[F[_]] {
notifyJoex: Boolean
): F[UpdateResult]
/** Submits a task that finds all non-converted pdfs and triggers
* converting them using ocrmypdf. Each file is converted by a
* separate task.
/** Submits a task that finds all non-converted pdfs and triggers converting them using
* ocrmypdf. Each file is converted by a separate task.
*/
def convertAllPdf(
collective: Option[Ident],
@ -191,8 +188,7 @@ trait OItem[F[_]] {
notifyJoex: Boolean
): F[UpdateResult]
/** Submits a task that (re)generates the preview image for an
* attachment.
/** Submits a task that (re)generates the preview image for an attachment.
*/
def generatePreview(
args: MakePreviewArgs,
@ -200,8 +196,7 @@ trait OItem[F[_]] {
notifyJoex: Boolean
): F[UpdateResult]
/** Submits a task that (re)generates the preview images for all
* attachments.
/** Submits a task that (re)generates the preview images for all attachments.
*/
def generateAllPreviews(
storeMode: MakePreviewArgs.StoreMode,

View File

@ -183,7 +183,7 @@ object OItemSearch {
def findAttachment(id: Ident, collective: Ident): F[Option[AttachmentData[F]]] =
store
.transact(RAttachment.findByIdAndCollective(id, collective))
.flatMap({
.flatMap {
case Some(ra) =>
makeBinaryData(ra.fileId) { m =>
AttachmentData[F](
@ -195,7 +195,7 @@ object OItemSearch {
case None =>
(None: Option[AttachmentData[F]]).pure[F]
})
}
def findAttachmentSource(
id: Ident,
@ -203,7 +203,7 @@ object OItemSearch {
): F[Option[AttachmentSourceData[F]]] =
store
.transact(RAttachmentSource.findByIdAndCollective(id, collective))
.flatMap({
.flatMap {
case Some(ra) =>
makeBinaryData(ra.fileId) { m =>
AttachmentSourceData[F](
@ -215,7 +215,7 @@ object OItemSearch {
case None =>
(None: Option[AttachmentSourceData[F]]).pure[F]
})
}
def findAttachmentPreview(
id: Ident,
@ -223,7 +223,7 @@ object OItemSearch {
): F[Option[AttachmentPreviewData[F]]] =
store
.transact(RAttachmentPreview.findByIdAndCollective(id, collective))
.flatMap({
.flatMap {
case Some(ra) =>
makeBinaryData(ra.fileId) { m =>
AttachmentPreviewData[F](
@ -235,7 +235,7 @@ object OItemSearch {
case None =>
(None: Option[AttachmentPreviewData[F]]).pure[F]
})
}
def findItemPreview(
item: Ident,
@ -243,7 +243,7 @@ object OItemSearch {
): F[Option[AttachmentPreviewData[F]]] =
store
.transact(RAttachmentPreview.findByItemAndCollective(item, collective))
.flatMap({
.flatMap {
case Some(ra) =>
makeBinaryData(ra.fileId) { m =>
AttachmentPreviewData[F](
@ -255,7 +255,7 @@ object OItemSearch {
case None =>
(None: Option[AttachmentPreviewData[F]]).pure[F]
})
}
def findAttachmentArchive(
id: Ident,
@ -263,7 +263,7 @@ object OItemSearch {
): F[Option[AttachmentArchiveData[F]]] =
store
.transact(RAttachmentArchive.findByIdAndCollective(id, collective))
.flatMap({
.flatMap {
case Some(ra) =>
makeBinaryData(ra.fileId) { m =>
AttachmentArchiveData[F](
@ -275,7 +275,7 @@ object OItemSearch {
case None =>
(None: Option[AttachmentArchiveData[F]]).pure[F]
})
}
private def makeBinaryData[A](fileId: Ident)(f: FileMeta => A): F[Option[A]] =
store.bitpeace

View File

@ -64,14 +64,14 @@ object OOrganization {
): F[Vector[OrgAndContacts]] =
store
.transact(QOrganization.findOrgAndContact(account.collective, query, _.name))
.map({ case (org, cont) => OrgAndContacts(org, cont) })
.map { case (org, cont) => OrgAndContacts(org, cont) }
.compile
.toVector
def findOrg(account: AccountId, orgId: Ident): F[Option[OrgAndContacts]] =
store
.transact(QOrganization.getOrgAndContact(account.collective, orgId))
.map(_.map({ case (org, cont) => OrgAndContacts(org, cont) }))
.map(_.map { case (org, cont) => OrgAndContacts(org, cont) })
def findAllOrgRefs(
account: AccountId,
@ -91,14 +91,14 @@ object OOrganization {
): F[Vector[PersonAndContacts]] =
store
.transact(QOrganization.findPersonAndContact(account.collective, query, _.name))
.map({ case (person, org, cont) => PersonAndContacts(person, org, cont) })
.map { case (person, org, cont) => PersonAndContacts(person, org, cont) }
.compile
.toVector
def findPerson(account: AccountId, persId: Ident): F[Option[PersonAndContacts]] =
store
.transact(QOrganization.getPersonAndContact(account.collective, persId))
.map(_.map({ case (pers, org, cont) => PersonAndContacts(pers, org, cont) }))
.map(_.map { case (pers, org, cont) => PersonAndContacts(pers, org, cont) })
def findAllPersonRefs(
account: AccountId,

View File

@ -19,31 +19,27 @@ import docspell.store.queries.SearchSummary
import org.log4s.getLogger
/** A "porcelain" api on top of OFulltext and OItemSearch. This takes
* care of restricting the items to a subset, e.g. only items that
* have a "valid" state.
/** A "porcelain" api on top of OFulltext and OItemSearch. This takes care of restricting
* the items to a subset, e.g. only items that have a "valid" state.
*/
trait OSimpleSearch[F[_]] {
/** Search for items using the given query and optional fulltext
* search.
/** Search for items using the given query and optional fulltext search.
*
* When using fulltext search only (the query is empty), only the
* index is searched. It is assumed that the index doesn't contain
* "invalid" items. When using a query, then a condition to select
* only valid items is added to it.
* When using fulltext search only (the query is empty), only the index is searched. It
* is assumed that the index doesn't contain "invalid" items. When using a query, then
* a condition to select only valid items is added to it.
*/
def search(settings: Settings)(q: Query, fulltextQuery: Option[String]): F[Items]
/** Using the same arguments as in `search`, this returns a summary
* and not the results.
/** Using the same arguments as in `search`, this returns a summary and not the results.
*/
def searchSummary(
settings: StatsSettings
)(q: Query, fulltextQuery: Option[String]): F[SearchSummary]
/** Calls `search` by parsing the given query string into a query that
* is then amended wtih the given `fix` query.
/** Calls `search` by parsing the given query string into a query that is then amended
* wtih the given `fix` query.
*/
final def searchByString(
settings: Settings
@ -52,8 +48,7 @@ trait OSimpleSearch[F[_]] {
): F[StringSearchResult[Items]] =
OSimpleSearch.applySearch[F, Items](fix, q)((iq, fts) => search(settings)(iq, fts))
/** Same as `searchByString` but returning a summary instead of the
* results.
/** Same as `searchByString` but returning a summary instead of the results.
*/
final def searchSummaryByString(
settings: StatsSettings
@ -190,8 +185,8 @@ object OSimpleSearch {
}
}
/** Calls `run` with one of the success results when extracting the
* fulltext search node from the query.
/** Calls `run` with one of the success results when extracting the fulltext search node
* from the query.
*/
private def runQuery[F[_]: Applicative, A](
itemQuery: Option[ItemQuery]
@ -211,10 +206,9 @@ object OSimpleSearch {
final class Impl[F[_]: Sync](fts: OFulltext[F], is: OItemSearch[F])
extends OSimpleSearch[F] {
/** Implements searching like this: it exploits the fact that teh
* fulltext index only contains valid items. When searching via
* sql the query expression selecting only valid items is added
* here.
/** Implements searching like this: it exploits the fact that teh fulltext index only
* contains valid items. When searching via sql the query expression selecting only
* valid items is added here.
*/
def search(
settings: Settings

View File

@ -31,10 +31,9 @@ trait OUpload[F[_]] {
itemId: Option[Ident]
): F[OUpload.UploadResult]
/** Submit files via a given source identifier. The source is looked
* up to identify the collective the files belong to. Metadata
* defined in the source is used as a fallback to those specified
* here (in UploadData).
/** Submit files via a given source identifier. The source is looked up to identify the
* collective the files belong to. Metadata defined in the source is used as a fallback
* to those specified here (in UploadData).
*/
def submit(
data: OUpload.UploadData[F],
@ -103,8 +102,7 @@ object OUpload {
def noSource: UploadResult = NoSource
/** When adding files to an item, no item was found using the given
* item-id.
/** When adding files to an item, no item was found using the given item-id.
*/
case object NoItem extends UploadResult

View File

@ -37,8 +37,7 @@ trait OUserTask[F[_]] {
task: UserTask[ScanMailboxArgs]
): F[Unit]
/** Return the settings for all the notify-due-items task of the
* current user.
/** Return the settings for all the notify-due-items task of the current user.
*/
def getNotifyDueItems(scope: UserTaskScope): Stream[F, UserTask[NotifyDueItemsArgs]]
@ -59,9 +58,8 @@ trait OUserTask[F[_]] {
/** Removes a user task with the given id. */
def deleteTask(scope: UserTaskScope, id: Ident): F[Unit]
/** Discards the schedule and immediately submits the task to the job
* executor's queue. It will not update the corresponding periodic
* task.
/** Discards the schedule and immediately submits the task to the job executor's queue.
* It will not update the corresponding periodic task.
*/
def executeNow[A](scope: UserTaskScope, subject: Option[String], task: UserTask[A])(
implicit E: Encoder[A]

View File

@ -16,8 +16,7 @@ object SendResult {
*/
case class Success(id: Ident) extends SendResult
/** There was a failure sending the mail. The mail is then not saved
* to db.
/** There was a failure sending the mail. The mail is then not saved to db.
*/
case class SendFailure(ex: Throwable) extends SendResult
@ -25,8 +24,7 @@ object SendResult {
*/
case class StoreFailure(ex: Throwable) extends SendResult
/** Something could not be found required for sending (mail configs,
* items etc).
/** Something could not be found required for sending (mail configs, items etc).
*/
case object NotFound extends SendResult
}