Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

mount: allow files of unkown size to be read properly

Nick Craig-Wood0baafb158f6d
diff --git a/cmd/cmount/fs.go b/cmd/cmount/fs.go
index 9d732be34..1ae98cc96 100644
--- a/cmd/cmount/fs.go
+++ b/cmd/cmount/fs.go
@@ -299,6 +299,9 @@ func (fsys *FS) Open(path string, flags int) (errc int, fh uint64) {
return translateError(err), fhUnset
}
+ // FIXME add support for unknown length files setting direct_io
+ // See: https://github.com/billziss-gh/cgofuse/issues/38
+
return 0, fsys.openHandle(handle)
}
diff --git a/cmd/mount/file.go b/cmd/mount/file.go
index 6a26af1fa..4bc7c3d45 100644
--- a/cmd/mount/file.go
+++ b/cmd/mount/file.go
@@ -73,6 +73,11 @@ func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenR
return nil, translateError(err)
}
+ // If size unknown then use direct io to read
+ if handle.Node().DirEntry().Size() < 0 {
+ resp.Flags |= fuse.OpenDirectIO
+ }
+
return &FileHandle{handle}, nil
}
diff --git a/docs/content/drive.md b/docs/content/drive.md
index bb58a7327..3e094b2ce 100644
--- a/docs/content/drive.md
+++ b/docs/content/drive.md
@@ -882,9 +882,12 @@ without downloading them.
Google docs will transfer correctly with `rclone sync`, `rclone copy`
etc as rclone knows to ignore the size when doing the transfer.
-However an unfortunate consequence of this is that you can't download
-Google docs using `rclone mount` - you will get a 0 sized file. If
-you try again the doc may gain its correct size and be downloadable.
+However an unfortunate consequence of this is that you may not be able
+to download Google docs using `rclone mount`. If it doesn't work you
+will get a 0 sized file. If you try again the doc may gain its
+correct size and be downloadable. Whther it will work on not depends
+on the application accessing the mount and the OS you are running -
+experiment to find out if it does work for you!
### Duplicated files ###
diff --git a/docs/content/googlephotos.md b/docs/content/googlephotos.md
index ed2f24341..6a66d69a4 100644
--- a/docs/content/googlephotos.md
+++ b/docs/content/googlephotos.md
@@ -277,13 +277,14 @@ that when syncing to Google Photos, rclone can only do a file
existence check.
It is possible to read the size of the media, but this needs an extra
-HTTP HEAD request per media item so is very slow and uses up a lot of
+HTTP HEAD request per media item so is **very slow** and uses up a lot of
transactions. This can be enabled with the `--gphotos-read-size`
option or the `read_size = true` config parameter.
-If you want to use the backend with `rclone mount` you will need to
-enable this flag otherwise you will not be able to read media off the
-mount.
+If you want to use the backend with `rclone mount` you may need to
+enable this flag (depending on your OS and application using the
+photos) otherwise you may not be able to read media off the mount.
+You'll need to experiment to see if it works for you without the flag.
### Albums