mirror of
https://github.com/rclone/rclone.git
synced 2025-01-09 15:58:28 +01:00
vfs: fix crash when truncating a just uploaded object - Fixes #5522
This commit is contained in:
parent
7a31ef783a
commit
e87de7c7e3
@ -744,7 +744,6 @@ func (f *File) Truncate(size int64) (err error) {
|
|||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
writers := make([]Handle, len(f.writers))
|
writers := make([]Handle, len(f.writers))
|
||||||
copy(writers, f.writers)
|
copy(writers, f.writers)
|
||||||
o := f.o
|
|
||||||
f.mu.Unlock()
|
f.mu.Unlock()
|
||||||
|
|
||||||
// FIXME: handle closing writer
|
// FIXME: handle closing writer
|
||||||
@ -761,6 +760,12 @@ func (f *File) Truncate(size int64) (err error) {
|
|||||||
return err
|
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 no writers, and size is already correct then all done
|
||||||
if o.Size() == size {
|
if o.Size() == size {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user