|
20 | 20 | */
|
21 | 21 | namespace Pydio\Access\Metastore\Implementation;
|
22 | 22 |
|
| 23 | +use Pydio\Access\Core\MetaStreamWrapper; |
23 | 24 | use Pydio\Access\Core\Model\AJXP_Node;
|
24 | 25 | use Pydio\Core\Controller\Controller;
|
25 | 26 | use Pydio\Access\Meta\Core\AbstractMetaSource;
|
26 | 27 | use Pydio\Access\Metastore\Core\IMetaStoreProvider;
|
| 28 | +use Pydio\Core\Utils\TextEncoder; |
| 29 | +use Pydio\Core\Utils\Vars\PathUtils; |
| 30 | +use Pydio\Core\Utils\Vars\StatHelper; |
27 | 31 |
|
28 | 32 | defined('AJXP_EXEC') or die( 'Access not allowed');
|
29 | 33 | /**
|
@@ -103,6 +107,7 @@ public function setMetadata($ajxpNode, $nameSpace, $metaData, $private = false,
|
103 | 107 | * @param String $nameSpace
|
104 | 108 | * @param bool $private
|
105 | 109 | * @param int $scope
|
| 110 | + * @return array|void |
106 | 111 | */
|
107 | 112 | public function removeMetadata($ajxpNode, $nameSpace, $private = false, $scope=AJXP_METADATA_SCOPE_REPOSITORY)
|
108 | 113 | {
|
@@ -312,10 +317,22 @@ protected function saveMetaFileData($ajxpNode, $scope, $userId)
|
312 | 317 | unset(self::$fullMetaCache[$metaFile][$fileKey]);
|
313 | 318 | }
|
314 | 319 | }
|
315 |
| - $fp = @fopen($metaFile, "w"); |
| 320 | + $writeMode = "w"; |
| 321 | + $nodeIsWinLocal = false; |
| 322 | + if($scope === AJXP_METADATA_SCOPE_GLOBAL && $this->nodeIsLocalWindowsFS($ajxpNode) && file_exists($metaFile)){ |
| 323 | + $nodeIsWinLocal = true; |
| 324 | + $writeMode = "rw+"; |
| 325 | + } |
| 326 | + $fp = @fopen($metaFile, $writeMode); |
316 | 327 | if ($fp !== false) {
|
317 | 328 | @fwrite($fp, serialize(self::$fullMetaCache[$metaFile]), strlen(serialize(self::$fullMetaCache[$metaFile])));
|
318 | 329 | @fclose($fp);
|
| 330 | + if($nodeIsWinLocal){ |
| 331 | + $real_path_metafile = TextEncoder::toStorageEncoding(realpath(MetaStreamWrapper::getRealFSReference($metaFile))); |
| 332 | + if (is_dir(dirname($real_path_metafile))) { |
| 333 | + StatHelper::winSetHidden($real_path_metafile); |
| 334 | + } |
| 335 | + } |
319 | 336 | }else{
|
320 | 337 | $this->logError(__FUNCTION__, "Error while trying to open the meta file, maybe a permission problem?");
|
321 | 338 | }
|
@@ -360,44 +377,11 @@ public function collectChildrenWithRepositoryMeta($ajxpNode, $nameSpace, $userSc
|
360 | 377 | }
|
361 | 378 |
|
362 | 379 | /**
|
363 |
| - * @param \Pydio\Access\Core\Model\AJXP_Node|null $srcNode |
364 |
| - * @param \Pydio\Access\Core\Model\AJXP_Node|null $destNode |
365 |
| - * @param bool|false $copy |
| 380 | + * @param AJXP_Node $ajxpNode |
| 381 | + * @return bool |
366 | 382 | */
|
367 |
| - public function nodeChangeHook($srcNode = null, $destNode = null, $copy = false){ |
368 |
| - // This is not called, it's the responsibility of the meta provider/setter to |
369 |
| - // handle the node.change event. |
370 |
| - // For example, it would break the ShareCenter "shares" management. |
371 |
| - /* |
372 |
| - if($srcNode == null || $copy) return; |
373 |
| - $operation = $destNode == null ? "delete" : "move"; |
374 |
| - $repositoryId = $srcNode->getRepositoryId(); |
375 |
| - $metaFile = $this->globalMetaFile."_".$repositoryId; |
376 |
| - $metaFile = $this->updateSecurityScope($metaFile, $srcNode->getRepositoryId(), $srcNode->getUser()); |
377 |
| - if(!is_file($metaFile)) return; |
378 |
| - $raw_data = file_get_contents($metaFile); |
379 |
| - if($raw_data === false) return; |
380 |
| - $metadata = unserialize($raw_data); |
381 |
| - if($metadata === false || !is_array($metadata)) return; |
382 |
| - $changes = false; |
383 |
| - $srcPath = $srcNode->getPath(); |
384 |
| - foreach($metadata as $path => $data){ |
385 |
| - preg_match("#^".preg_quote($srcPath, "#")."/#", $path, $matches); |
386 |
| - if($path == $srcPath || count($matches)){ |
387 |
| - if($operation == "move"){ |
388 |
| - if($path == $srcPath) $newPath = $destNode->getPath(); |
389 |
| - else $newPath = preg_replace("#^".preg_quote($srcPath, "#")."#", $destNode->getPath(), $path); |
390 |
| - $metadata[$newPath] = $data; |
391 |
| - } |
392 |
| - unset($metadata[$path]); |
393 |
| - $changes = true; |
394 |
| - } |
395 |
| - } |
396 |
| - if($changes){ |
397 |
| - // Should update $metadata now. |
398 |
| - @file_put_contents($metaFile, serialize($metadata)); |
399 |
| - } |
400 |
| - */ |
| 383 | + private function nodeIsLocalWindowsFS($ajxpNode){ |
| 384 | + return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && !MetaStreamWrapper::wrapperIsRemote($ajxpNode->getUrl())); |
401 | 385 | }
|
402 | 386 |
|
403 | 387 | /**
|
|
0 commit comments