From 244fbf747c46d435f3237e3d7eef07826cd5707f Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 4 Aug 2021 15:16:08 +0800 Subject: [PATCH] rename use file id --- disk/Onedrive.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/disk/Onedrive.php b/disk/Onedrive.php index 8972d77..2f59e5c 100644 --- a/disk/Onedrive.php +++ b/disk/Onedrive.php @@ -342,7 +342,8 @@ class Onedrive { $oldname = path_format($file['path'] . '/' . $oldname); $data = '{"name":"' . $newname . '"}'; //echo $oldname; - $result = $this->MSAPI('PATCH', $oldname, $data); + if ($file['id']) $result = $this->MSAPI('PATCH', "/items/" . $file['id'], $data); + else $result = $this->MSAPI('PATCH', $oldname, $data); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); } public function Delete($file) { @@ -946,6 +947,9 @@ class Onedrive { $url = $this->api_url . $this->ext_api_url; if ($path=='' or $path=='/') { $url .= '/'; + } elseif (substr($path, 0, 6)=="/items") { + $url = substr($url, 0, -5); + $url .= $path; } else { $url .= ':' . $path; if (substr($url,-1)=='/') $url=substr($url,0,-1);