<commit_before>//
// worker.go -- rabbitmq worker
//
package srnd

import (
  "log"
  "os/exec"
  "strconv"
  "strings"
)

func WorkerInit() bool {
  // check for config
  CheckConfig()
  return true
}

// process a line
// do an action given the command
func workerDoLine(line string, conf map[string]string, database Database) {
  parts := strings.Split(line, " ")
  action := parts[0]
  if len(parts) < 2 {
    return
  }
  args := parts[1:]
  if action == "thumbnail" {
    // assume full filepath
    infname, outfname := args[0], args[1]
    cmd := exec.Command(conf["convert"], "-thumbnail", "200", infname, outfname)
    exec_out, exec_err := cmd.CombinedOutput()
    log.Println("[MQ] result:", exec_err, string(exec_out))
  } else if action == "ukko" {
    template.genUkko(args[0], args[1], args[2], database)
  } else if action == "front" {
    template.genFrontPage(10, args[1], args[2], database)
  } else if action == "board-page" {
    page, _ := strconv.ParseInt(args[3], 10, 32)
    template.genBoardPage(args[0], args[1], args[2], int(page), args[4], database)
  } else if action == "board-all" {
    template.genBoard(args[0], args[1], args[2], args[3], database)
  } else if action == "thread" {
    template.genThread(args[0], args[1], args[2], args[3], database)<commit_msg>check bounds for worker<commit_after>//
// worker.go -- rabbitmq worker
//
package srnd

import (
  "log"
  "os/exec"
  "strconv"
  "strings"
)

func WorkerInit() bool {
  // check for config
  CheckConfig()
  return true
}

// process a line
// do an action given the command
func workerDoLine(line string, conf map[string]string, database Database) {
  parts := strings.Split(line, " ")
  action := parts[0]
  if len(parts) < 2 {
    return
  }
  args := parts[1:]
  if action == "thumbnail" && len(args) == 2 {
    // assume full filepath
    infname, outfname := args[0], args[1]
    cmd := exec.Command(conf["convert"], "-thumbnail", "200", infname, outfname)
    exec_out, exec_err := cmd.CombinedOutput()
    log.Println("[MQ] result:", exec_err, string(exec_out))
  } else if action == "ukko" && len(args) == 3 {
    template.genUkko(args[0], args[1], args[2], database)
  } else if action == "front" && len(args) == 3 {
    template.genFrontPage(10, args[1], args[2], database)
  } else if action == "board-page" && len(args) == 5 {
    page, _ := strconv.ParseInt(args[3], 10, 32)
    template.genBoardPage(args[0], args[1], args[2], int(page), args[4], database)
  } else if action == "board-all" && len(args) == 4 {
    template.genBoard(args[0], args[1], args[2], args[3], database)
  } else if action == "thread" && len(args) == 4 {
    template.genThread(args[0], args[1], args[2], args[3], database)
{'fraction_non_alphanumeric': 0.18067846607669616, 'fraction_numerical': 0.025811209439528023, 'mean_word_length': 3.6775862068965517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5130562', 'n_tokens_mistral': 990, 'n_tokens_neox': 958, 'n_words': 248}