luis 7 роки тому
батько
коміт
94f5959a8b

+ 8 - 10
internal/fs/gdrivefs/file_container.go

@@ -22,15 +22,11 @@ func NewFileContainer(fs *GDriveFS) *FileContainer {
 		fileEntries: map[fuseops.InodeID]*FileEntry{},
 		fs:          fs,
 		inodeMU:     &sync.Mutex{},
+		uid:         fs.config.UID,
+		gid:         fs.config.GID,
 	}
 	rootEntry := fc.FileEntry(fuseops.RootInodeID)
-
-	rootEntry.Attr = fuseops.InodeAttributes{
-		Mode: os.FileMode(0755) | os.ModeDir,
-		Uid:  fs.config.UID,
-		Gid:  fs.config.GID,
-	}
-	rootEntry.isDir = true
+	rootEntry.Attr.Mode = os.FileMode(0755) | os.ModeDir
 	fc.tree = rootEntry
 
 	return fc
@@ -74,9 +70,11 @@ func (fc *FileContainer) FileEntry(inodeOps ...fuseops.InodeID) *FileEntry {
 	fe := &FileEntry{
 		Inode:     inode,
 		container: fc,
-		//fs:        fc.fs,
-		children: []*FileEntry{},
-		Attr:     fuseops.InodeAttributes{},
+		children:  []*FileEntry{},
+		Attr: fuseops.InodeAttributes{
+			Uid: fc.uid,
+			Gid: fc.gid,
+		},
 	}
 	fc.fileEntries[inode] = fe
 

+ 4 - 1
internal/fs/gdrivefs/file_entry.go

@@ -20,7 +20,6 @@ type FileEntry struct {
 	container *FileContainer
 	//fs    *GDriveFS
 	GFile *drive.File // GDrive file
-	isDir bool        // Is dir
 	Name  string      // local name
 	// fuseops
 	Inode fuseops.InodeID
@@ -254,6 +253,10 @@ func (fe *FileEntry) FindByName(name string, recurse bool) *FileEntry {
 	return nil
 }
 
+func (fe *FileEntry) IsDir() bool {
+	return fe.Attr.Mode&os.ModeDir == os.ModeDir
+}
+
 // FindByGID find by google drive ID
 /*func (fe *FileEntry) FindByGID(gdriveID string, recurse bool) *FileEntry {
 	// Recurse??

+ 1 - 1
internal/fs/gdrivefs/gdrivefs.go

@@ -254,7 +254,7 @@ func (fs *GDriveFS) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) (err err
 
 		for i, v := range fh.entry.children {
 			fusetype := fuseutil.DT_File
-			if v.isDir {
+			if v.IsDir() {
 				fusetype = fuseutil.DT_Directory
 			}
 			dirEnt := fuseutil.Dirent{

BIN
test/cloudmount