replace rename() by exec('mv ..')

This commit is contained in:
Uwe Steinmann 2021-11-08 09:01:15 +01:00
parent 334639cbb5
commit b7b92bcc57

View File

@ -488,7 +488,7 @@ class SeedDMS_Extension_Mgr {
*/ */
public function updateExtension($file) { /* {{{ */ public function updateExtension($file) { /* {{{ */
/* unzip the extension in a temporary directory */ /* unzip the extension in a temporary directory */
$newdir = $this->cachedir ."/ext.new"; $newdir = addDirSep($this->cachedir)."ext.new";
/* First remove a left over from a previous extension */ /* First remove a left over from a previous extension */
if(file_exists($newdir)) { if(file_exists($newdir)) {
self::rrmdir($newdir); self::rrmdir($newdir);
@ -529,7 +529,21 @@ class SeedDMS_Extension_Mgr {
$this->rrmdir($this->extdir ."/". $extname); $this->rrmdir($this->extdir ."/". $extname);
} }
/* Move the temp. created ext directory to the final location */ /* Move the temp. created ext directory to the final location */
if(!rename($newdir, $this->extdir ."/". $extname)) { /* rename() may fail if dirs are moved from one device to another.
* See https://bugs.php.net/bug.php?id=54097
*
* exec("mv ".escapeshellarg($newdir)." ".escapeshellarg($this->extdir ."/". $extname));
*
* It's also sufficient to just copy the extracted archive to the final
* 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 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->rrmdir($this->extdir ."/". $extname); $this->rrmdir($this->extdir ."/". $extname);
return false; return false;
} }