Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix EncFS and caching issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jan 2, 2017
1 parent 5c39993 commit 980895f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions core/src/plugins/cypher.encfs/EncfsMounter.php
Expand Up @@ -25,6 +25,8 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\RecycleBinManager;
use Pydio\Access\Core\Model\UserSelection;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Http\Message\ReloadMessage;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Utils\Vars\InputFilter;

Expand Down Expand Up @@ -159,10 +161,16 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
}
rmdir($dir);
self::umountFolder($clear);
$newNode = $node->getParent()->createChildNode(basename($clear));
Controller::applyHook("node.change", [null, &$newNode], true);
$newNode->loadNodeInfo(true);
}
} else if (substr(basename($dir), 0, strlen("ENCFS_CLEAR_")) == "ENCFS_CLEAR_") {
// SIMPLY UNMOUNT
self::umountFolder($dir);
// Reload node
Controller::applyHook("node.change", [&$node, &$node], true);
$node->loadNodeInfo(true);
}
break;

Expand All @@ -175,13 +183,12 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
if (is_dir($raw)) {
self::mountFolder($raw, $dir, $pass, $uid);
}
$node->loadNodeInfo(true);
break;
}

$x = new \Pydio\Core\Http\Response\SerializableResponseStream();
$diff = new \Pydio\Access\Core\Model\NodesDiff();
$diff->update($node);
$x->addChunk($diff);
$x->addChunk(new ReloadMessage("", $node->getPath()));
$responseInterface = $responseInterface->withBody($x);

}
Expand All @@ -196,17 +203,18 @@ public function filterENCFS(&$ajxpNode, $parentNode = false, $details = false)
{
if (substr($ajxpNode->getLabel(), 0, strlen("ENCFS_RAW_")) == "ENCFS_RAW_") {
$ajxpNode->hidden = true;
} else if (substr($ajxpNode->getLabel(), 0, strlen("ENCFS_CLEAR_")) == "ENCFS_CLEAR_") {
} else if (strpos(basename($ajxpNode->getPath()), "ENCFS_CLEAR_") === 0) {
$ajxpNode->ENCFS_clear_folder = true;
$ajxpNode->overlay_icon = "cypher.encfs/overlay_ICON_SIZE.png";
$ajxpNode->overlay_class = "icon-lock";
$ajxpNode->ajxp_readonly = "true";
if (is_file($ajxpNode->getUrl() . "/.ajxp_mount")) {
$ajxpNode->setLabel(substr($ajxpNode->getLabel(), strlen("ENCFS_CLEAR_")));
$ajxpNode->setLabel(substr(basename($ajxpNode->getPath()), strlen("ENCFS_CLEAR_")));
$ajxpNode->ENCFS_clear_folder_mounted = true;
$ajxpNode->ajxp_readonly = "false";
} else {
$ajxpNode->setLabel(substr($ajxpNode->getLabel(), strlen("ENCFS_CLEAR_")) . " (encrypted)");
$ajxpNode->ENCFS_clear_folder_mounted = false;
$ajxpNode->setLabel(substr(basename($ajxpNode->getPath()), strlen("ENCFS_CLEAR_")) . " (encrypted)");
}
}
}
Expand Down Expand Up @@ -288,7 +296,7 @@ public static function mountFolder($raw, $clear, $secret, $uid)
if (!empty($error)) {
throw new Exception("Error mounting volume : " . $error);
}
if (stristr($text, "error")) {
if (!empty($text)) {
throw new Exception("Error mounting volume : " . $text);
}
// Mount should have succeeded now
Expand Down

0 comments on commit 980895f

Please sign in to comment.