PackageManager just because
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
942 B

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
}