onedrive: fix crash if no metadata was updated

Before this change, rclone would crash if no metadata was updated.
This could happen if the --onedrive-metadata-permissions read was
supplied but metadata to write was supplied.

Fixes #8586
This commit is contained in:
Nick Craig-Wood
2025-06-06 15:33:42 +01:00
parent 768a4236e6
commit 99358cee88
2 changed files with 14 additions and 3 deletions

View File

@@ -1782,7 +1782,9 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dst fs.Obj
if err != nil {
return nil, err
}
err = dstObj.setMetaData(info)
if info != nil {
err = dstObj.setMetaData(info)
}
return dstObj, err
}
@@ -1862,7 +1864,9 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
if err != nil {
return nil, err
}
err = dstObj.setMetaData(info)
if info != nil {
err = dstObj.setMetaData(info)
}
return dstObj, err
}
@@ -2629,7 +2633,10 @@ func (o *Object) uploadSinglepart(ctx context.Context, in io.Reader, src fs.Obje
if err != nil {
return nil, fmt.Errorf("failed to fetch and update metadata: %w", err)
}
return info, o.setMetaData(info)
if info != nil {
err = o.setMetaData(info)
}
return info, err
}
// Update the object with the contents of the io.Reader, modTime and size