Files
forever-files/main.go
2024-06-01 17:30:15 -06:00

57 lines
1.4 KiB
Go

package main
import (
"fmt"
"forever-files/db"
"forever-files/fileUtilities"
"forever-files/partitioner"
"forever-files/source"
"forever-files/types"
)
func main() {
fmt.Printf("%v\n", types.AppName)
baseDir := "C:\\Users\\gomas\\Nextcloud"
store, err := db.NewDB(types.AppName)
if err != nil {
panic(fmt.Errorf("error creating db: %w", err))
}
defer store.Close()
err = store.Migrate()
if err != nil {
panic(fmt.Errorf("error migrating db: %w", err))
}
source.GatherInfo(baseDir, store)
oneDVDSize := int64(4600000000)
partitions, err := partitioner.CalculatePartitions(store, oneDVDSize)
if err != nil {
panic(fmt.Errorf("error calculating partitions: %w", err))
}
// zip up the files in each partition
partitionCount := len(partitions)
for i, partition := range partitions {
fileName := fmt.Sprintf("partition%0*d", getZeroPadAmount(partitionCount), i)
fmt.Printf("Creating zip file: %v\n", fileName)
err = fileUtilities.CreateZip(fileName, "C:\\tmp\\", baseDir, partition)
if err != nil {
panic(fmt.Errorf("error creating zip: %w", err))
}
}
// create parities for each zip file pair, figure out how to store the length of each zip file with the parity
// create a folder for each DVD add the scripts and zip files
// copy the zip files to the DVD
}
func getZeroPadAmount(n int) int {
str := fmt.Sprintf("%d", n)
return len(str)
}