package Filesystem import ( "PackageManager/Client/Database" "PackageManager/Client/ProgressBar" "PackageManager/Variables" "github.com/vbauerster/mpb" bolt "go.etcd.io/bbolt" ) func CommitFiles() error { var ( fsStatus FilesystemStatus indexBucket *bolt.Bucket bar *mpb.Bar f string e error ) fsStatus, e = GetFilesystemDiff(Variables.RootDir) if e != nil { return e } e = Database.FsDB.Batch(func(tx *bolt.Tx) error { indexBucket = tx.Bucket(Variables.FsHashIndexBucket) if len(fsStatus.PickedFiles) > 0 { bar = ProgressBar.InitBar("Commiting...", len(fsStatus.PickedFiles)) for _, f = range fsStatus.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 }