File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -370,10 +370,22 @@ public function rename($path1, $path2) {
370
370
return false ;
371
371
}
372
372
}
373
+ // We need to get the object for the existing file with the same
374
+ // name (if there is one) before we do the patch. If oldfile
375
+ // exists and is a directory we have to delete it before we
376
+ // do the rename too.
377
+ $ oldfile = $ this ->getDriveFile ($ path2 );
378
+ if ($ oldfile && $ this ->is_dir ($ path2 )) {
379
+ $ this ->rmdir ($ path2 );
380
+ $ oldfile = false ;
381
+ }
373
382
$ result = $ this ->service ->files ->patch ($ file ->getId (), $ file );
374
383
if ($ result ) {
375
384
$ this ->setDriveFile ($ path1 , false );
376
385
$ this ->setDriveFile ($ path2 , $ result );
386
+ if ($ oldfile ) {
387
+ $ this ->service ->files ->delete ($ oldfile ->getId ());
388
+ }
377
389
}
378
390
return (bool )$ result ;
379
391
} else {
You can’t perform that action at this time.
0 commit comments