Skip to content

Instantly share code, notes, and snippets.

@msmorul
Created October 23, 2014 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msmorul/daac6ef355eca41815a2 to your computer and use it in GitHub Desktop.
Save msmorul/daac6ef355eca41815a2 to your computer and use it in GitHub Desktop.
patch for fixing zipping files over the smb driver in pyd.io
--- class.smbAccessDriver.php.orig 2014-10-23 11:15:47.699206429 -0400
+++ class.smbAccessDriver.php 2014-10-23 11:21:50.423194343 -0400
@@ -86,16 +86,33 @@
require_once(AJXP_BIN_FOLDER."/pclzip.lib.php");
$filePaths = array();
foreach ($src as $item) {
- $realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase.(($item[0] == "/")? "" : "/").AJXP_Utils::securePath($item));
- $basedir = trim(dirname($realFile))."/";
- $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile,
- PCLZIP_ATT_FILE_NEW_SHORT_NAME => basename($item));
+ $realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase."/".$item);
+ $realFile = AJXP_Utils::securePath($realFile);
+ if (basename($item) == "") {
+ $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile);
+ } else {
+ $shortName = basename($item);
+ if(!empty($zipEncoding)){
+ $test = iconv(SystemTextEncoding::getEncoding(), $zipEncoding, $shortName);
+ if($test !== false) $shortName = $test;
+ }
+ $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile,
+ PCLZIP_ATT_FILE_NEW_SHORT_NAME => $shortName);
+ }
}
$this->logDebug("Pathes", $filePaths);
$this->logDebug("Basedir", array($basedir));
self::$filteringDriverInstance = $this;
$archive = new PclZip($dest);
- $vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON);
+
+ if($basedir == "__AJXP_ZIP_FLAT__/"){
+ $vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback');
+ }else{
+ $basedir = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase).trim($basedir);
+ $this->logDebug("Basedir", array($basedir));
+ $vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback');
+ }
+
if (!$vList) {
throw new Exception("Zip creation error : ($dest) ".$archive->errorInfo(true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment