<commit_before>// This file is part of *kellner*
//
// Copyright (C) 2015, Travelping GmbH <<EMAIL>>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package main

import (
	"net/http"
	"os"
	"path/filepath"
)

func makeIndexHandler(root, cache string) http.Handler {

	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

		var (
			path     = filepath.Join(root, r.URL.Path)
			baseName = filepath.Base(path)
		)

		switch baseName {
		case "Packages", "Packages.gz", "Packages.stamps":
			var cachedPath = filepath.Join(cache, baseName)
			http.ServeFile(w, r, cachedPath)
			return
		}

		var fi os.FileInfo
		var err error
		if fi, err = os.Stat(path); err != nil {
			http.NotFound(w, r)
			return
		}

		if fi.IsDir() {
			renderIndex(w, r, path, root, cache)<commit_msg>fix: serve Packages* files from the -cache directory<commit_after>// This file is part of *kellner*
//
// Copyright (C) 2015, Travelping GmbH <<EMAIL>>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package main

import (
	"net/http"
	"os"
	"path/filepath"
)

func makeIndexHandler(root, cache string) http.Handler {

	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

		var (
			path     = filepath.Join(root, r.URL.Path)
			baseName = filepath.Base(path)
		)

		switch baseName {
		case "Packages", "Packages.gz", "Packages.stamps":
			var cachedPath = filepath.Join(cache, r.URL.Path)
			http.ServeFile(w, r, cachedPath)
			return
		}

		var fi os.FileInfo
		var err error
		if fi, err = os.Stat(path); err != nil {
			http.NotFound(w, r)
			return
		}

		if fi.IsDir() {
			renderIndex(w, r, path, root, cache)
{'fraction_non_alphanumeric': 0.13083632632119035, 'fraction_numerical': 0.008209338122113904, 'mean_word_length': 3.1577825159914714, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '1602800', 'n_tokens_mistral': 767, 'n_tokens_neox': 683, 'n_words': 216}