Skip to content
Snippets Groups Projects
Commit 703aff6c authored by Bart Visscher's avatar Bart Visscher
Browse files

Run proxies and emit signals when finising chunked upload

Otherwise the file cache and the quota isn't checked
parent 30188847
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
$chunk_handler->store($info['index'], $data);
if ($chunk_handler->isComplete()) {
$newPath = $this->path . '/' . $info['name'];
$f = OC_Filesystem::fopen($newPath, 'w');
$chunk_handler->assemble($f);
$chunk_handler->file_assemble($newPath);
return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
}
} else {
......
......@@ -55,12 +55,13 @@ class OC_FileChunking {
public function assemble($f) {
$cache = $this->getCache();
$prefix = $this->getPrefix();
$count = 0;
for($i=0; $i < $this->info['chunkcount']; $i++) {
$chunk = $cache->get($prefix.$i);
$cache->remove($prefix.$i);
fwrite($f,$chunk);
$count += fwrite($f,$chunk);
}
fclose($f);
return $count;
}
public function signature_split($orgfile, $input) {
......@@ -91,4 +92,57 @@ class OC_FileChunking {
'count' => $count,
);
}
public function file_assemble($path) {
$absolutePath = OC_Filesystem::normalizePath(OC_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_Filesystem::isValidPath($path)) {
$path = OC_Filesystem::getView()->getRelativePath($absolutePath);
$exists = OC_Filesystem::file_exists($path);
$run = true;
if(!$exists) {
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_create,
array(
OC_Filesystem::signal_param_path => $path,
OC_Filesystem::signal_param_run => &$run
)
);
}
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_write,
array(
OC_Filesystem::signal_param_path => $path,
OC_Filesystem::signal_param_run => &$run
)
);
if(!$run) {
return false;
}
$target = OC_Filesystem::fopen($path, 'w');
if($target) {
$count = $this->assemble($target);
fclose($target);
if(!$exists) {
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_post_create,
array( OC_Filesystem::signal_param_path => $path)
);
}
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_post_write,
array( OC_Filesystem::signal_param_path => $path)
);
OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
return $count > 0;
}else{
return false;
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment