<commit_before>package main

import (
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path"
	"sync/atomic"
	"time"
)

// An Image contains information on a particular image URL, as well as the user where the URL was found.
type Image struct {
	User          string
	URL           string
	UnixTimestamp int64
}

// Download downloads an image specified in an Image's URL.
func (i Image) Download() {
	resp, err := http.Get(i.URL)

	if err != nil {
		log.Println(err)
		atomic.AddUint64(&totalErrors, 1)
		return
	}
	defer resp.Body.Close()

	pic, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}

	file := "downloads/" + i.User + "/" + path.Base(i.URL)

	err = ioutil.WriteFile(file, pic, 0644)
	if err != nil {
		log.Fatal(err)
	}

	err = os.Chtimes(file, time.Now(), time.Unix(i.UnixTimestamp, 0))
	if err != nil {
		log.Println(err)
	}

	atomic.AddUint64(&totalDownloaded, 1)

}

// Standard String method for the Stringer interface.
func (i Image) String() string {
	return i.User + " - " + path.Base(i.URL)
}<commit_msg>Download output now prints when a post was created. Resolves #5.<commit_after>package main

import (
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path"
	"sync/atomic"
	"time"
)

// An Image contains information on a particular image URL, as well as the user where the URL was found.
type Image struct {
	User          string
	URL           string
	UnixTimestamp int64
}

// Download downloads an image specified in an Image's URL.
func (i Image) Download() {
	resp, err := http.Get(i.URL)

	if err != nil {
		log.Println(err)
		atomic.AddUint64(&totalErrors, 1)
		return
	}
	defer resp.Body.Close()

	pic, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}

	file := "downloads/" + i.User + "/" + path.Base(i.URL)

	err = ioutil.WriteFile(file, pic, 0644)
	if err != nil {
		log.Fatal(err)
	}

	err = os.Chtimes(file, time.Now(), time.Unix(i.UnixTimestamp, 0))
	if err != nil {
		log.Println(err)
	}

	atomic.AddUint64(&totalDownloaded, 1)

}

// Standard String method for the Stringer interface.
func (i Image) String() string {
	date := time.Unix(i.UnixTimestamp, 0)
	return i.User + " - " + date.Format("2006-01-02 15:04:05") + " - " + path.Base(i.URL)
}
{'fraction_non_alphanumeric': 0.14576731552738795, 'fraction_numerical': 0.019013128112267994, 'mean_word_length': 3.1619585687382297, 'pattern_counts': {'":': 0, '<': 3, '<?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': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6040603', 'n_tokens_mistral': 893, 'n_tokens_neox': 831, 'n_words': 231}