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 err error ) err = 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() err = AddFileToBucket(indexBucket, f) if err != nil { return nil } } err = tx.DeleteBucket(Variables.FsHashPicksBucket) if err != nil { return err } } return nil }) return err }