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 { e = AddFileToBucket(indexBucket, f) bar.Increment() if e != nil { return e } } e = tx.DeleteBucket(Variables.FsHashPicksBucket) if e != nil { return e } ProgressBar.CloseBar(bar) } return nil }) return e }