add zip and parity stuff
This commit is contained in:
34
main.go
34
main.go
@ -3,23 +3,53 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"forever-files/db"
|
||||
"forever-files/source"
|
||||
"forever-files/fileUtilities"
|
||||
"forever-files/partitioner"
|
||||
"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("C:\\Users\\gomas\\Nextcloud", store)
|
||||
//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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user