package Filesystem import ( "PackageManager/Client/Database" "PackageManager/Client/ProgressBar" "PackageManager/Variables" "github.com/vbauerster/mpb" bolt "go.etcd.io/bbolt" ) func CommitFiles() error { var ( indexBucket *bolt.Bucket picksBucket *bolt.Bucket bar *mpb.Bar pickedFiles []string f string e error ) e = Database.FsDB.Batch(func(tx *bolt.Tx) error { indexBucket = tx.Bucket(Variables.FsHashIndexBucket) picksBucket = tx.Bucket(Variables.FsHashPicksBucket) picksBucket.ForEach(func(k, v []byte) error { pickedFiles = append(pickedFiles, string(k)) return nil }) if len(pickedFiles) > 0 { bar = ProgressBar.InitBar("Commiting...", len(pickedFiles)) for _, f = range pickedFiles { bar.Increment() e = AddFileToBucket(indexBucket, f) if e != nil { return nil } } e = tx.DeleteBucket(Variables.FsHashPicksBucket) if e != nil { return e } ProgressBar.CloseBar(bar) } return nil }) return e }