Skip to content

Commit

Permalink
rename use file id
Browse files Browse the repository at this point in the history
  • Loading branch information
qkqpttgf committed Aug 4, 2021
1 parent 47bf970 commit 244fbf7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion disk/Onedrive.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ public function Rename($file, $newname) {
$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) {
Expand Down Expand Up @@ -946,6 +947,9 @@ protected function MSAPI($method, $path, $data = '', $headers = [])
$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);
Expand Down

0 comments on commit 244fbf7

Please sign in to comment.