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.

48 lines
774 B

3 years ago
  1. package Filesystem
  2. import (
  3. "PackageManager/Client/Database"
  4. "PackageManager/Variables"
  5. "fmt"
  6. bolt "go.etcd.io/bbolt"
  7. )
  8. func CommitFiles() error {
  9. var (
  10. fsStatus FilesystemStatus
  11. indexBucket *bolt.Bucket
  12. f string
  13. e error
  14. )
  15. fsStatus, e = GetFilesystemDiff(Variables.RootDir)
  16. if e != nil {
  17. return e
  18. }
  19. e = Database.FsDB.Batch(func(tx *bolt.Tx) error {
  20. indexBucket = tx.Bucket(Variables.FsHashIndexBucket)
  21. if len(fsStatus.PickedFiles) > 0 {
  22. for _, f = range fsStatus.PickedFiles {
  23. fmt.Println(f)
  24. e = AddFileToBucket(indexBucket, f)
  25. if e != nil {
  26. return e
  27. }
  28. }
  29. /*
  30. e = tx.DeleteBucket(Variables.FsHashPicksBucket)
  31. if e != nil {
  32. return e
  33. }
  34. */
  35. }
  36. return nil
  37. })
  38. return e
  39. }