use rename() on windows when moving an extension to its final destination

This commit is contained in:
Uwe Steinmann 2024-09-02 16:00:17 +02:00
parent 15c5ef1441
commit f97c42f9b7

View File

@ -565,12 +565,16 @@ class SeedDMS_Extension_Mgr {
* location and leave the extracted archive in place. The next time an
* extension is imported the last extracted archive will be removed.
*/
// if(!rename($newdir, $this->extdir ."/". $extname)) {
if(false === exec('mv '.escapeshellarg($newdir).' '.escapeshellarg($this->extdir."/".$extname))) {
if(strpos(PHP_OS, 'WIN') === 0)
$ret = rename($newdir, $this->extdir ."/". $extname);
else
$ret = exec('mv '.escapeshellarg($newdir).' '.escapeshellarg($this->extdir."/".$extname));
if(false === $ret) {
/* If copy didn't succeed, then there is probably nothing to delete,
* but do it anyway, just to be sure not just parts of the extension
* has been copied.
*/
$this->errmsgs[] = "Cannot move temp. extension directory to final destination";
$this->rrmdir($this->extdir ."/". $extname);
return false;
}