mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 08:23:47 +01:00
vfs: fix crash when truncating a just uploaded object - Fixes #5522
This commit is contained in:
parent
bec253fd39
commit
a5f277f47e
@ -744,7 +744,6 @@ func (f *File) Truncate(size int64) (err error) {
|
||||
f.mu.Lock()
|
||||
writers := make([]Handle, len(f.writers))
|
||||
copy(writers, f.writers)
|
||||
o := f.o
|
||||
f.mu.Unlock()
|
||||
|
||||
// FIXME: handle closing writer
|
||||
@ -761,6 +760,12 @@ func (f *File) Truncate(size int64) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// if o is nil it isn't valid yet
|
||||
o, err := f.waitForValidObject()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If no writers, and size is already correct then all done
|
||||
if o.Size() == size {
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user