gfile.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Tempoarry in basefs since we dont have the service yet
  2. package basefs
  3. import (
  4. "os"
  5. "time"
  6. "github.com/jacobsa/fuse/fuseops"
  7. drive "google.golang.org/api/drive/v3"
  8. )
  9. type GFile struct {
  10. *drive.File
  11. }
  12. func (gf *GFile) ID() string {
  13. return gf.Id
  14. }
  15. func (gf *GFile) Name() string {
  16. return gf.File.Name
  17. }
  18. func (gf *GFile) Parents() []string {
  19. return gf.File.Parents
  20. }
  21. func (gf *GFile) Attr() fuseops.InodeAttributes {
  22. attr := fuseops.InodeAttributes{}
  23. attr.Nlink = 1
  24. //attr.Uid = fe.container.uid
  25. //attr.Gid = fe.container.gid
  26. attr.Mode = os.FileMode(0644) // default
  27. //if gfile != nil {
  28. attr.Size = uint64(gf.File.Size)
  29. attr.Crtime, _ = time.Parse(time.RFC3339, gf.File.CreatedTime)
  30. attr.Ctime = attr.Crtime // Set CTime to created, although it is change inode metadata
  31. attr.Mtime, _ = time.Parse(time.RFC3339, gf.File.ModifiedTime)
  32. attr.Atime = attr.Mtime // Set access time to modified, not sure if gdrive has access time
  33. if gf.MimeType == "application/vnd.google-apps.folder" {
  34. attr.Mode = os.FileMode(0755) | os.ModeDir
  35. }
  36. return attr
  37. }