mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-11-03 18:00:11 +00:00 
			
		
		
		
	Use max-mails setting with higher priority
				
					
				
			The `mail-chunk-size` is set to its configured value or `max-mails` whichever is lower.
This commit is contained in:
		@@ -106,14 +106,18 @@ docspell.joex {
 | 
			
		||||
      max-folders = 50
 | 
			
		||||
 | 
			
		||||
      # How many mails (headers only) to retrieve in one chunk.
 | 
			
		||||
      mail-chunk-size = 100
 | 
			
		||||
      #
 | 
			
		||||
      # If this is greater than `max-mails' it is set automatically to
 | 
			
		||||
      # the value of `max-mails'.
 | 
			
		||||
      mail-chunk-size = 50
 | 
			
		||||
 | 
			
		||||
      # A limit on how many mails to process in one job run. This is
 | 
			
		||||
      # only to avoid resource allocation to one user/collective.
 | 
			
		||||
      # meant to avoid too heavy resource allocation to one
 | 
			
		||||
      # user/collective.
 | 
			
		||||
      #
 | 
			
		||||
      # If more than this number of mails is encountered, a warning is
 | 
			
		||||
      # logged.
 | 
			
		||||
      max-mails = 1000
 | 
			
		||||
      max-mails = 500
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,9 @@ case class Config(
 | 
			
		||||
object Config {
 | 
			
		||||
  case class Bind(address: String, port: Int)
 | 
			
		||||
 | 
			
		||||
  case class ScanMailbox(maxFolders: Int, mailChunkSize: Int, maxMails: Int)
 | 
			
		||||
  case class ScanMailbox(maxFolders: Int, mailChunkSize: Int, maxMails: Int) {
 | 
			
		||||
    def mailBatchSize: Int =
 | 
			
		||||
      math.min(mailChunkSize, maxMails)
 | 
			
		||||
  }
 | 
			
		||||
  case class UserTasks(scanMailbox: ScanMailbox)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -164,11 +164,11 @@ object ScanMailboxTask {
 | 
			
		||||
      for {
 | 
			
		||||
        _ <- Kleisli.liftF(
 | 
			
		||||
          ctx.logger.debug(
 | 
			
		||||
            s"Searching next ${cfg.mailChunkSize} mails in ${folder.name}."
 | 
			
		||||
            s"Searching next ${cfg.mailBatchSize} mails in ${folder.name}."
 | 
			
		||||
          )
 | 
			
		||||
        )
 | 
			
		||||
        query <- Kleisli.liftF(q)
 | 
			
		||||
        mails <- a.search(folder, cfg.mailChunkSize)(query)
 | 
			
		||||
        mails <- a.search(folder, cfg.mailBatchSize)(query)
 | 
			
		||||
        _ <- Kleisli.liftF(
 | 
			
		||||
          ctx.logger.debug(
 | 
			
		||||
            s"Found ${mails.count} mails in folder. Reading first ${mails.mails.size}"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user