Permalink
Browse files

Set metastore files hidden if possible. Should fix #1077

  • Loading branch information...
1 parent 2a81ee7 commit f4de5d8a9dcc3c02813d7b7397778b107b614d57 @cdujeu cdujeu committed Sep 29, 2016
@@ -20,10 +20,14 @@
*/
namespace Pydio\Access\Metastore\Implementation;
+use Pydio\Access\Core\MetaStreamWrapper;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Core\Controller\Controller;
use Pydio\Access\Meta\Core\AbstractMetaSource;
use Pydio\Access\Metastore\Core\IMetaStoreProvider;
+use Pydio\Core\Utils\TextEncoder;
+use Pydio\Core\Utils\Vars\PathUtils;
+use Pydio\Core\Utils\Vars\StatHelper;
defined('AJXP_EXEC') or die( 'Access not allowed');
/**
@@ -103,6 +107,7 @@ public function setMetadata($ajxpNode, $nameSpace, $metaData, $private = false,
* @param String $nameSpace
* @param bool $private
* @param int $scope
+ * @return array|void
*/
public function removeMetadata($ajxpNode, $nameSpace, $private = false, $scope=AJXP_METADATA_SCOPE_REPOSITORY)
{
@@ -312,10 +317,22 @@ protected function saveMetaFileData($ajxpNode, $scope, $userId)
unset(self::$fullMetaCache[$metaFile][$fileKey]);
}
}
- $fp = @fopen($metaFile, "w");
+ $writeMode = "w";
+ $nodeIsWinLocal = false;
+ if($scope === AJXP_METADATA_SCOPE_GLOBAL && $this->nodeIsLocalWindowsFS($ajxpNode) && file_exists($metaFile)){
+ $nodeIsWinLocal = true;
+ $writeMode = "rw+";
+ }
+ $fp = @fopen($metaFile, $writeMode);
if ($fp !== false) {
@fwrite($fp, serialize(self::$fullMetaCache[$metaFile]), strlen(serialize(self::$fullMetaCache[$metaFile])));
@fclose($fp);
+ if($nodeIsWinLocal){
+ $real_path_metafile = TextEncoder::toStorageEncoding(realpath(MetaStreamWrapper::getRealFSReference($metaFile)));
+ if (is_dir(dirname($real_path_metafile))) {
+ StatHelper::winSetHidden($real_path_metafile);
+ }
+ }
}else{
$this->logError(__FUNCTION__, "Error while trying to open the meta file, maybe a permission problem?");
}
@@ -360,44 +377,11 @@ public function collectChildrenWithRepositoryMeta($ajxpNode, $nameSpace, $userSc
}
/**
- * @param \Pydio\Access\Core\Model\AJXP_Node|null $srcNode
- * @param \Pydio\Access\Core\Model\AJXP_Node|null $destNode
- * @param bool|false $copy
+ * @param AJXP_Node $ajxpNode
+ * @return bool
*/
- public function nodeChangeHook($srcNode = null, $destNode = null, $copy = false){
- // This is not called, it's the responsibility of the meta provider/setter to
- // handle the node.change event.
- // For example, it would break the ShareCenter "shares" management.
- /*
- if($srcNode == null || $copy) return;
- $operation = $destNode == null ? "delete" : "move";
- $repositoryId = $srcNode->getRepositoryId();
- $metaFile = $this->globalMetaFile."_".$repositoryId;
- $metaFile = $this->updateSecurityScope($metaFile, $srcNode->getRepositoryId(), $srcNode->getUser());
- if(!is_file($metaFile)) return;
- $raw_data = file_get_contents($metaFile);
- if($raw_data === false) return;
- $metadata = unserialize($raw_data);
- if($metadata === false || !is_array($metadata)) return;
- $changes = false;
- $srcPath = $srcNode->getPath();
- foreach($metadata as $path => $data){
- preg_match("#^".preg_quote($srcPath, "#")."/#", $path, $matches);
- if($path == $srcPath || count($matches)){
- if($operation == "move"){
- if($path == $srcPath) $newPath = $destNode->getPath();
- else $newPath = preg_replace("#^".preg_quote($srcPath, "#")."#", $destNode->getPath(), $path);
- $metadata[$newPath] = $data;
- }
- unset($metadata[$path]);
- $changes = true;
- }
- }
- if($changes){
- // Should update $metadata now.
- @file_put_contents($metaFile, serialize($metadata));
- }
- */
+ private function nodeIsLocalWindowsFS($ajxpNode){
+ return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && !MetaStreamWrapper::wrapperIsRemote($ajxpNode->getUrl()));
}
/**
@@ -10,11 +10,4 @@
<param name="METADATA_FILE_LOCATION" type="select" choices="infolders|CONF_MESSAGE[In Local Folders],outside|CONF_MESSAGE[Application Data Folder]" label="CONF_MESSAGE[File location]" description="CONF_MESSAGE[Where to store the metadata file : LOCAL means a hidden file will be created in each folder, GLOBAL means that one file will be created in AJXP_DATA_PATH/plugins/action.share folder.]" mandatory="true" default="infolders"/>
<param name="METADATA_FILE" type="string" label="CONF_MESSAGE[Meta File]" description="CONF_MESSAGE[Hidden file used inside folders to save meta data]" mandatory="true" default=".ajxp_meta"/>
</server_settings>
- <registry_contributions>
-<!--
- <hooks>
- <serverCallback hookName="node.change" methodName="nodeChangeHook"/>
- </hooks>
--->
- </registry_contributions>
</metastore>

0 comments on commit f4de5d8

Please sign in to comment.