Index: /extensions/autoupdate/autoupdate.php
===================================================================
--- /extensions/autoupdate/autoupdate.php	(revision 4006)
+++ /extensions/autoupdate/autoupdate.php	(revision 4007)
@@ -83,32 +83,69 @@
     include_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
     $zip = new PclZip($file);
-    if ($result = $zip->extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH, PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'], PCLZIP_OPT_REPLACE_NEWER))
+    if ($result = $zip->extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH,
+                                PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'],
+                                PCLZIP_OPT_SET_CHMOD, 0755,
+                                PCLZIP_OPT_REPLACE_NEWER))
     {
-      if (file_exists(PHPWG_ROOT_PATH.'obsolete.list')
-        and $old_files = file(PHPWG_ROOT_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES)
-        and !empty($old_files))
+      //Check if all files were extracted
+      $error = '';
+      foreach($result as $extract)
       {
-        array_push($old_files, 'obsolete.list');
-        foreach($old_files as $old_file)
+        if (!in_array($extract['status'], array('ok', 'filtered', 'already_a_directory')))
         {
-          $path = PHPWG_ROOT_PATH.$old_file;
-          if (is_file($path))
+          // Try to change chmod and extract
+          if (@chmod(PHPWG_ROOT_PATH.$extract['filename'], 0777)
+            and ($res = $zip->extract(PCLZIP_OPT_BY_NAME, $_GET['autoupdate'].'/'.$extract['filename'],
+                                      PCLZIP_OPT_PATH, PHPWG_ROOT_PATH,
+                                      PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'],
+                                      PCLZIP_OPT_SET_CHMOD, 0755,
+                                      PCLZIP_OPT_REPLACE_NEWER))
+            and isset($res[0]['status'])
+            and $res[0]['status'] == 'ok')
           {
-            @unlink($path);
+            continue;
           }
-          elseif (is_dir($path))
+          else
           {
-            autoupdate_deltree($path);
+            $error .= $extract['filename'].': '.$extract['status']."\n";
           }
         }
       }
-      if (preg_match('/\d+\.\d+\.\d+_to_(\d+\.\d+\.\d+)/', $_GET['autoupdate'], $matches))
+
+      if (empty($error))
       {
-        check_version_for_autoupdate($matches[1]);
+        if (file_exists(PHPWG_ROOT_PATH.'obsolete.list')
+          and $old_files = file(PHPWG_ROOT_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES)
+          and !empty($old_files))
+        {
+          array_push($old_files, 'obsolete.list');
+          foreach($old_files as $old_file)
+          {
+            $path = PHPWG_ROOT_PATH.$old_file;
+            if (is_file($path))
+            {
+              @unlink($path);
+            }
+            elseif (is_dir($path))
+            {
+              autoupdate_deltree($path);
+            }
+          }
+        }
+        if (preg_match('/\d+\.\d+\.\d+_to_(\d+\.\d+\.\d+)/', $_GET['autoupdate'], $matches))
+        {
+          check_version_for_autoupdate($matches[1]);
+        }
+        autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
+        invalidate_user_cache(true);
+        $template->delete_compiled_templates();
+        redirect('admin.php?autoupdate=success');
       }
-      autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
-      invalidate_user_cache(true);
-      $template->delete_compiled_templates();
-      redirect('admin.php?autoupdate=success');
+      else
+      {
+        file_put_contents($conf['local_data_dir'].'/autoupdate/log_error.txt', $error);
+        $relative_path = trim(str_replace(dirname(dirname(dirname(__FILE__))), '', $conf['local_data_dir']), '/\\');
+        array_push($page['errors'], sprintf(l10n('autoupdate_extract_fail'), PHPWG_ROOT_PATH.$relative_path.'/autoupdate/log_error.txt'));
+      }
     }
     else
Index: /extensions/autoupdate/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/autoupdate/language/en_UK/plugin.lang.php	(revision 4006)
+++ /extensions/autoupdate/language/en_UK/plugin.lang.php	(revision 4007)
@@ -6,3 +6,5 @@
 $lang['autoupdate_fail'] = 'An error occured during upgrade.';
 
+$lang['autoupdate_extract_fail'] = 'An error occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.';
+
 ?>
Index: /extensions/autoupdate/language/es_ES/plugin.lang.php
===================================================================
--- /extensions/autoupdate/language/es_ES/plugin.lang.php	(revision 4006)
+++ /extensions/autoupdate/language/es_ES/plugin.lang.php	(revision 4007)
@@ -6,3 +6,5 @@
 $lang['autoupdate_fail'] = 'Un error sobrevino durante la puesta al día.';
 
+/*TODO*/$lang['autoupdate_extract_fail'] = 'An error occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.';
+
 ?>
Index: /extensions/autoupdate/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/autoupdate/language/fr_FR/plugin.lang.php	(revision 4006)
+++ /extensions/autoupdate/language/fr_FR/plugin.lang.php	(revision 4007)
@@ -6,3 +6,5 @@
 $lang['autoupdate_fail'] = 'Une erreur est survenue pendant la mise à jour.';
 
+$lang['autoupdate_extract_fail'] = 'Impossible d\'extraire les fichiers. Veuillez vérifier les permissions des fichiers de votre installation.<br><a href="%s">Cliquez ici pour voir le rapport d\'erreur</a>.';
+
 ?>
Index: /extensions/autoupdate/language/it_IT/plugin.lang.php
===================================================================
--- /extensions/autoupdate/language/it_IT/plugin.lang.php	(revision 4006)
+++ /extensions/autoupdate/language/it_IT/plugin.lang.php	(revision 4007)
@@ -6,3 +6,5 @@
 $lang['autoupdate_fail'] = 'Si è verificato un\'errore durante l\'aggiornamento.';
 
+/*TODO*/$lang['autoupdate_extract_fail'] = 'An error occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.';
+
 ?>
Index: /extensions/autoupdate/language/pl_PL/plugin.lang.php
===================================================================
--- /extensions/autoupdate/language/pl_PL/plugin.lang.php	(revision 4006)
+++ /extensions/autoupdate/language/pl_PL/plugin.lang.php	(revision 4007)
@@ -6,3 +6,5 @@
 $lang['autoupdate_fail'] = 'Wystąpił błąd podczas aktualizacji.';
 
+/*TODO*/$lang['autoupdate_extract_fail'] = 'An error occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.';
+
 ?>
