فهرست منبع

Return ENOSYS if truncate is not 0

luis 7 سال پیش
والد
کامیت
87d52d2f53
3فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 1 1
      src/gdrivemount/cmd/gdrivemount/version.go
  2. 1 3
      src/gdrivemount/fileentry.go
  3. 7 1
      src/gdrivemount/gdrive-fuse.go

+ 1 - 1
src/gdrivemount/cmd/gdrivemount/version.go

@@ -2,5 +2,5 @@ package main
 
 const (
   //Version contains version of the package
-  Version = "0.0.1-2-ge531499 - built: 2017-07-07 04:27:44 UTC"
+  Version = "0.1 - built: 2017-07-07 10:30:51 UTC"
 )

+ 1 - 3
src/gdrivemount/fileentry.go

@@ -131,9 +131,8 @@ func (fe *FileEntry) Cache() *os.File {
 	}
 	var res *http.Response
 	var err error
-	log.Println("Caching file:", fe.GFile.Name)
 	// Export GDocs (Special google doc documents needs to be exported make a config somewhere for this)
-	switch fe.GFile.MimeType {
+	switch fe.GFile.MimeType { // Make this somewhat optional
 	case "application/vnd.google-apps.document":
 		log.Println("Exporting as: text/markdown")
 		res, err = fe.fs.srv.Files.Export(fe.GFile.Id, "text/plain").Download()
@@ -159,7 +158,6 @@ func (fe *FileEntry) Cache() *os.File {
 	}
 	io.Copy(fe.tempFile, res.Body)
 
-	log.Println("Caching done", fe.GFile.Name)
 	fe.tempFile.Seek(0, io.SeekStart)
 	return fe.tempFile
 

+ 7 - 1
src/gdrivemount/gdrive-fuse.go

@@ -302,8 +302,14 @@ func (fs *GDriveFS) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) (err err
 func (fs *GDriveFS) SetInodeAttributes(ctx context.Context, op *fuseops.SetInodeAttributesOp) (err error) {
 
 	// Hack to truncate file?
-	if op.Size != nil && *op.Size == 0 { // Request to truncate i supose?
+
+	if op.Size != nil {
 		f := fs.root.FindByInode(op.Inode, true)
+
+		if *op.Size != 0 { // We only allow truncate to 0
+			return fuse.ENOSYS
+		}
+		// Delete and create another on truncate 0
 		err = fs.srv.Files.Delete(f.GFile.Id).Do() // XXX: Careful on this
 		createdFile, err := fs.srv.Files.Create(&drive.File{Parents: f.GFile.Parents, Name: f.GFile.Name}).Do()
 		if err != nil {