-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
41 lines (36 loc) · 1.03 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"ramooz.org/deleteOldBackup/components/ftp"
"ramooz.org/deleteOldBackup/configs"
"ramooz.org/deleteOldBackup/managers"
)
func main() {
jsonData, err := ioutil.ReadFile("configs/configs.json")
if err != nil {
fmt.Println("config file not found", err)
os.Exit(1)
}
serviceConfig := map[string]interface{}{}
if err := json.Unmarshal(jsonData, &serviceConfig); err != nil {
fmt.Println("config file didn't parsing to json", err)
os.Exit(1)
}
ftpConfigMap := serviceConfig["ftp_account"].(map[string]interface{})
ftpConfig := &ftp.FtpConfig{
Address: ftpConfigMap["address"].(string),
Username: ftpConfigMap["username"].(string),
Password: ftpConfigMap["password"].(string),
}
deleteConfig := &configs.DeleteOldFileConfig{
DeleteAfter_Month: 3,
DeleteAfter_Week: 3,
DeleteAfter_Days: 3,
KeepLastFileInFolder: true,
DeleteEmptyFolder: true,
}
managers.DeleteOldFiles(ftpConfigMap["deletable_files_path"].(string), deleteConfig, ftpConfig)
}