58 lines
1.4 KiB
Go
58 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)
|
|
//oneBRSize := int64(25000000000) // size of a small Blu-ray disc
|
|
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)
|
|
}
|