<commit_before>package main

import (
	"compress/gzip"
	"errors"
	"flag"
	"io"
	"log"
	"net/http"
	"os"
	"path"
	"path/filepath"
	"time"

	"github.com/daaku/go.httpgzip"
	"github.com/gorilla/mux"
)

var fListen = flag.String("listen", "localhost:8080", "host and port to listen on")
var fDB = flag.String("db", "purchases.db", "sqlite3 database file")
var fUsername = flag.String("username", "test", "username for basic auth")
var fPassword = flag.String("password", "password", "password for basic auth")

func backup() error {
	src, err := os.Open(*fDB)
	defer src.Close()
	if err != nil {
		return errors.New("could not open database to backup")
	}

	backupPath := path.Join(filepath.Dir(*fDB), "backup")
	err = os.MkdirAll(backupPath, 0755)
	if err != nil {
		return errors.New("could not create backup")
	}

	destFile := path.Join(backupPath, filepath.Base(*fDB)+".gz")
	dest, err := os.Create(destFile)
	defer dest.Close()
	if err != nil {
		return err
	}

	gzipWriter := gzip.NewWriter(dest)
	_, err = io.Copy(gzipWriter, src)
	if err != nil {
		return err
	}

	return gzipWriter.Close()<commit_msg>test change<commit_after>package main

import (
	"compress/gzip"
	"errors"
	"flag"
	"io"
	"log"
	"net/http"
	"os"
	"path"
	"path/filepath"
	"time"

	"github.com/daaku/go.httpgzip"
	"github.com/gorilla/mux"
)

var fListen = flag.String("listen", "localhost:8080", "host and port to listen on")
var fDB = flag.String("db", "purchases.db", "sqlite3 database file")
var fUsername = flag.String("username", "test", "username for basic auth")
var fPassword = flag.String("password", "<PASSWORD>", "password for basic auth")

func backup() error {
	src, err := os.Open(*fDB)
	defer src.Close()
	if err != nil {
		return errors.New("could not open database to backup")
	}

	backupPath := path.Join(filepath.Dir(*fDB), "backup")
	err = os.MkdirAll(backupPath, 0755)
	if err != nil {
		return errors.New("could not create backup")
	}

	destFile := path.Join(backupPath, filepath.Base(*fDB)+".gz")
	dest, err := os.Create(destFile)
	defer dest.Close()
	if err != nil {
		return err
	}

	gzipWriter := gzip.NewWriter(dest)
	_, err = io.Copy(gzipWriter, src)
	if err != nil {
		return err
	}

	return gzipWriter.Close()
{'fraction_non_alphanumeric': 0.1654611211573237, 'fraction_numerical': 0.0081374321880651, 'mean_word_length': 4.319711538461538, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2023341', 'n_tokens_mistral': 855, 'n_tokens_neox': 824, 'n_words': 210}