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.

31 lines
576 B

3 years ago
3 years ago
3 years ago
  1. package Filesystem
  2. import (
  3. "os"
  4. bolt "go.etcd.io/bbolt"
  5. )
  6. func AddFileToBucket(bucket *bolt.Bucket, filePath string) error {
  7. var (
  8. fileObject FileObject
  9. fileObjectBytes []byte
  10. e error
  11. )
  12. fileObject, e = CreateFileObject(filePath)
  13. if os.IsNotExist(e) {
  14. return nil
  15. }
  16. if e != nil {
  17. return nil
  18. }
  19. fileObjectBytes, e = fileObject.ToBytes()
  20. if e != nil {
  21. return e
  22. }
  23. return bucket.Put([]byte(filePath), fileObjectBytes)
  24. }
  25. func RemoveFileFromBucket(bucket *bolt.Bucket, filePath string) error {
  26. return bucket.Delete([]byte(filePath))
  27. }