package Filesystem
|
|
|
|
import (
|
|
"PackageManager/Client/Database"
|
|
"PackageManager/Variables"
|
|
"fmt"
|
|
|
|
bolt "go.etcd.io/bbolt"
|
|
)
|
|
|
|
func CommitFiles() error {
|
|
var (
|
|
fsStatus FilesystemStatus
|
|
indexBucket *bolt.Bucket
|
|
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 {
|
|
for _, f = range fsStatus.PickedFiles {
|
|
fmt.Println(f)
|
|
e = AddFileToBucket(indexBucket, f)
|
|
if e != nil {
|
|
return e
|
|
}
|
|
}
|
|
|
|
/*
|
|
e = tx.DeleteBucket(Variables.FsHashPicksBucket)
|
|
if e != nil {
|
|
return e
|
|
}
|
|
*/
|
|
}
|
|
|
|
return nil
|
|
})
|
|
|
|
return e
|
|
}
|