Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fileproxy as storage wrapper #12701

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/private/filechunking.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ public function file_assemble($path) {
$absolutePath = \OC\Files\Filesystem::normalizePath(\OC\Files\Filesystem::getView()->getAbsolutePath($path));
$data = '';
// use file_put_contents as method because that best matches what this function does
if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data)
&& \OC\Files\Filesystem::isValidPath($path)) {
if (\OC\Files\Filesystem::isValidPath($path)) {
$path = \OC\Files\Filesystem::getView()->getRelativePath($absolutePath);
$exists = \OC\Files\Filesystem::file_exists($path);
$run = true;
Expand Down Expand Up @@ -210,7 +209,6 @@ public function file_assemble($path) {
\OC\Files\Filesystem::signal_post_write,
array( \OC\Files\Filesystem::signal_param_path => $path)
);
OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
return $count > 0;
}else{
return false;
Expand Down
14 changes: 14 additions & 0 deletions lib/private/fileproxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

class OC_FileProxy{
private static $proxies=array();
private static $wrapperSetup = false;
public static $enabled=true;

/**
Expand All @@ -64,6 +65,19 @@ public function __call($function, $arguments) {
* @param OC_FileProxy $proxy
*/
public static function register($proxy) {
if (!self::$wrapperSetup){
self::$wrapperSetup = true;
\OC\Files\Filesystem::addStorageWrapper('proxy', function($mountPoint, \OC\Files\Storage\Storage $storage) {
if($storage->instanceOfStorage('\OC\Files\Storage\Wrapper\Proxy')) {
return $storage;
} else {
return new \OC\Files\Storage\Wrapper\Proxy(array(
'storage' => $storage,
'mountpoint' => $mountPoint
));
}
});
}
self::$proxies[]=$proxy;
}

Expand Down
Loading