Magento CONNECT ERROR: Can’t write to file: downloader/.cache/community/

Article ID #1095
Revision: 1.2
Last update: 2011-10-12

 

Symptoms

Magento Connect in Magento 1.5 sometimes throws the following error message on attempt to install some extension (we have noticed this on BusinessDecision_Interaktingslider):

CONNECT ERROR: Can't write to file: downloader/.cache/community/BusinessDecision_Interaktingslider-1.0.6/app/code/community/BusinessDecision/Interaktingslider/sql/interaktingslider_setup/mysql4-install-1.0.6.php

 

You have checked all permissions and sure that the destination is writeable, yet the Magento Connect cannot create this file.

 

Cause

The reason is that function working with archives passing non-ASCII characters in the filename and the filename cannot be created simply due to filesystem restrictions on filenames.

 

Solution

The simple fix can be just patch the _writeFile function in downloader/lib/Mage/Archive/Abstract.php to strip all non-ASCII characters from the filename:

 

 

--- Abstract.php
+++ downloader/lib/Mage/Archive/Abstract.php
@@ -43,4 +43,5 @@
     protected function _writeFile($destination, $data)
     {
+        $destination = preg_replace('/[^(\x20-\x7F)]*/','', $destination);
         if(false === file_put_contents($destination, $data)) {
             throw new Mage_Exception("Can't write to file: " . $destination);

 

The fix has been applied already for all our new installations.

Did this article help you solve your issue?


Average rating: 3.97 (39 votes)

completely useless 1 2 3 4 5 most valuable

Tags: ,