vfs: make -ve sized files appear as 0 size. #320
This means that Google docs will no longer appear as huge files in `rclone mount`. They will not be downloadable, though sometimes trying twice will work.
This commit is contained in:
parent
2eb5cfb7ad
commit
44276db454
3 changed files with 18 additions and 2 deletions
|
@ -382,6 +382,14 @@ see User rate limit exceeded errors, wait at least 24 hours and retry.
|
||||||
You can disable server side copies with `--disable copy` to download
|
You can disable server side copies with `--disable copy` to download
|
||||||
and upload the files if you prefer.
|
and upload the files if you prefer.
|
||||||
|
|
||||||
|
Google docs will appear as size -1 in `rclone ls` and as size 0 in
|
||||||
|
anything which uses the VFS layer, eg `rclone mount`, `rclone serve
|
||||||
|
XXX`. This is because rclone can't find out the size of the Google
|
||||||
|
Documents until they are downloaded. 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.
|
||||||
|
|
||||||
### Duplicated files ###
|
### Duplicated files ###
|
||||||
|
|
||||||
Sometimes, for no reason I've been able to track down, drive will
|
Sometimes, for no reason I've been able to track down, drive will
|
||||||
|
|
10
vfs/file.go
10
vfs/file.go
|
@ -144,6 +144,14 @@ func (f *File) ModTime() (modTime time.Time) {
|
||||||
return f.d.modTime
|
return f.d.modTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nonNegative returns 0 if i is -ve, i otherwise
|
||||||
|
func nonNegative(i int64) int64 {
|
||||||
|
if i >= 0 {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// Size of the file
|
// Size of the file
|
||||||
func (f *File) Size() int64 {
|
func (f *File) Size() int64 {
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
|
@ -153,7 +161,7 @@ func (f *File) Size() int64 {
|
||||||
if f.o == nil || len(f.writers) != 0 {
|
if f.o == nil || len(f.writers) != 0 {
|
||||||
return atomic.LoadInt64(&f.size)
|
return atomic.LoadInt64(&f.size)
|
||||||
}
|
}
|
||||||
return f.o.Size()
|
return nonNegative(f.o.Size())
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetModTime sets the modtime for the file
|
// SetModTime sets the modtime for the file
|
||||||
|
|
|
@ -51,7 +51,7 @@ func newReadFileHandle(f *File, o fs.Object) (*ReadFileHandle, error) {
|
||||||
noSeek: f.d.vfs.Opt.NoSeek,
|
noSeek: f.d.vfs.Opt.NoSeek,
|
||||||
file: f,
|
file: f,
|
||||||
hash: mhash,
|
hash: mhash,
|
||||||
size: o.Size(),
|
size: nonNegative(o.Size()),
|
||||||
}
|
}
|
||||||
return fh, nil
|
return fh, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue