added caching of images to the drive

This commit is contained in:
partisan 2024-10-13 00:04:46 +02:00
parent 48994ee32d
commit 3d47c80446
11 changed files with 451 additions and 33 deletions

View file

@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"sync"
"time"
"github.com/fsnotify/fsnotify"
"gopkg.in/ini.v1"
@ -78,6 +79,7 @@ func saveConfig(config Config) {
sec.Key("CrawlerEnabled").SetValue(strconv.FormatBool(config.CrawlerEnabled))
sec.Key("WebsiteEnabled").SetValue(strconv.FormatBool(config.WebsiteEnabled))
sec.Key("LogLevel").SetValue(strconv.Itoa(config.LogLevel))
sec.Key("HardCacheDuration").SetValue(config.HardCacheDuration.String())
err := cfg.SaveTo(configFilePath)
if err != nil {
@ -130,16 +132,32 @@ func loadConfig() Config {
logLevel = 1
}
// Read HardCacheDuration
hardCacheStr := cfg.Section("").Key("HardCacheDuration").String()
var hardCacheDuration time.Duration
if hardCacheStr != "" {
duration, err := time.ParseDuration(hardCacheStr)
if err != nil {
printWarn("Invalid HardCacheDuration format, defaulting to 0: %v", err)
hardCacheDuration = 0
} else {
hardCacheDuration = duration
}
} else {
hardCacheDuration = 0 // Default to 0 if not set
}
config = Config{
Port: port,
AuthCode: cfg.Section("").Key("AuthCode").String(),
PeerID: cfg.Section("").Key("PeerID").String(),
Peers: peers,
Domain: domain,
NodesEnabled: nodesEnabled,
CrawlerEnabled: crawlerEnabled,
WebsiteEnabled: websiteEnabled,
LogLevel: logLevel,
Port: port,
AuthCode: cfg.Section("").Key("AuthCode").String(),
PeerID: cfg.Section("").Key("PeerID").String(),
Peers: peers,
Domain: domain,
NodesEnabled: nodesEnabled,
CrawlerEnabled: crawlerEnabled,
WebsiteEnabled: websiteEnabled,
LogLevel: logLevel,
HardCacheDuration: hardCacheDuration,
}
return config