Open Dheyvidj opened 2 months ago
@Dheyvidj It is interesting that "rename" causes a "copy" on your installation. Are the directories on your installation maybe located on different file systems?
@Dheyvidj It is interesting that "rename" causes a "copy" on your installation. Are the directories on your installation maybe located on different file systems?
My installation is in a Docker container that uses several volumes. I believe these volumes might be directly influencing the issue. However, I made some modifications to the code that worked for me, but I am not certain about its effectiveness in different installation environments.
I suspect that the use of Docker volumes might be causing rename() to fail and triggering an internal copy() operation.
Ok, thanks for the details. Actually, I would like to stay with a move operation, as it happens almost instantly compared to a copy operation.
Maybe we could add a FileHelper::moveDirectory()
functions, which:
mv
system command (if available) - it's safe to move via several volumesrename()
Sounds like a bug in yii PHP to me, unless it is clearly documented that it can't be used with directories across volumes. (At least the error message should be better.)
- Tries to move via
mv
system command (if available) - it's save to move via several volumes
Note that mv
can't move between filesystems either, it will, however, fall back to copy and delete without errors in most cases. If you rely on an atomic move or persistent file pointers that may not work. (I'd need to check the documentation for details.)
Found the bug reported in 2011: PHP :: Bug #54097 :: rename() of dirs accross devices produces confusing copy error
Is this language actually maintained any more? :thinking: Loads of people must have wasted their time with this being unfixed and undocumented. Be it on Windows, with tmp file systems and especially since containerization started.
We are experiencing an issue with the update package installation process in our application. Specifically, the problem occurs when trying to move directories using the
rename()
function, which results in an error. The error message is as follows:Detailed Problem:
The error occurs when attempting to move directories such as
vendor
,humhub
, andstatic
to the backup directory and replacing these directories with new ones from the update package. The current code uses therename()
function for this task, which does not support directory copy operations.Steps to Reproduce:
install()
function from theUpdatePackage
class.vendor
,humhub
, andstatic
directories to the backup directory and replace them with new directories.Impact:
rename()
function fails when trying to move directories, resulting in the failure of the update package installation.Proposed Solution:
Replace the use of the
rename()
function with a method that correctly copies and removes directories. It is suggested to use thecopyDirectory()
function to copy the directories and then remove the old directories usingFileHelper::removeDirectory()
.Current Code (for reference):
Suggested Code (with fix):
The fix will allow proper movement of directories during the update process.