<commit_before>/*
 * Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.eknet.publet.web

import grizzled.slf4j.Logging

/**
 * @author <NAME> <EMAIL>
 * @since 22.05.12 20:30
 */
class PartitionMounter extends EmptyExtension with Logging {

  override def onStartup() {
    val publet = PubletWeb.publet
    val partman = PubletWeb.gitpartman
    partman.getAllPartitions
      .collect({ case p if (p.getMountPoint.isDefined)=>p})
      .foreach(part => {
      info("Mounting repository '"+ part.tandem.name.name +"' to '"+ part.getMountPoint.get.asString+"'...")
      publet.mountManager.mount(part.getMountPoint.get, part)
    })
  }

}<commit_msg>adds ability to automount normal fs partitions on start<commit_after>/*
 * Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.eknet.publet.web

import grizzled.slf4j.Logging
import org.eknet.publet.vfs.Path
import org.eknet.publet.vfs.fs.FilesystemPartition
import java.io.File

/**
 * @author <NAME> <EMAIL>
 * @since 22.05.12 20:30
 */
class PartitionMounter extends EmptyExtension with Logging {

  override def onStartup() {
    import Path._
    val publet = PubletWeb.publet

    // git partitions
    val partman = PubletWeb.gitpartman
    partman.getAllPartitions
      .collect({ case p if (p.getMountPoint.isDefined)=>p})
      .foreach(part => {
      info("Mounting repository '"+ part.tandem.name.name +"' to '"+ part.getMountPoint.get.asString+"'...")
      publet.mountManager.mount(part.getMountPoint.get, part)
    })

    // fs partitions
    val fsKey = "partition.fs."
    val settings = PubletWeb.publetSettings
    def mountFs(num:Int): Int = {
      val dir = settings(fsKey + num +".dir")
      val mount = settings(fsKey + num +".mount")
      if (dir.isDefined && mount.isDefined) {
        val pdir = new File(Config.configDirectory, dir.get)
        info("Mounting fs directory '"+ dir.get+ "' to '"+ mount.get+"'")
        publet.mountManager.mount(mount.get.p, new FilesystemPartition(pdir, true))
        1+ mountFs(num +1)
      } else {
        0
      }
    }
    val partCount = mountFs(0)
    info("Mounted "+ partCount +" filesystem partition(s)")
  }



}
{'fraction_non_alphanumeric': 0.11207162704538438, 'fraction_numerical': 0.012966965112689102, 'mean_word_length': 3.263157894736842, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5627952', 'n_tokens_mistral': 1020, 'n_tokens_neox': 975, 'n_words': 311}