Skip to content
Snippets Groups Projects
Commit 1263511a authored by Jörn Friedrich Dreyer's avatar Jörn Friedrich Dreyer
Browse files

append .part to put files

parent 1c56539c
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,13 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
*/
public function put($data) {
\OC\Files\Filesystem::file_put_contents($this->path,$data);
// mark file as partial while uploading (ignored by the scanner)
$partpath = $this->path . '.part';
\OC\Files\Filesystem::file_put_contents($partpath, $data);
// rename to correct path
\OC\Files\Filesystem::rename($partpath, $this->path);
return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
}
......
......@@ -97,7 +97,7 @@ class Scanner {
if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
\OC_DB::beginTransaction();
while ($file = readdir($dh)) {
if ($file !== '.' and $file !== '..') {
if (!$this->isIgnoredFile($file)) {
$child = ($path) ? $path . '/' . $file : $file;
$data = $this->scanFile($child);
if ($data) {
......@@ -134,6 +134,22 @@ class Scanner {
return $size;
}
/**
* @brief check if the file should be ignored when scanning
* NOTE: files with a '.part' extension are ignored as well!
* prevents unfinished put requests to be scanned
* @param String $file
* @return boolean
*/
private function isIgnoredFile($file) {
if ($file === '.' || $file === '..'
|| pathinfo($file,PATHINFO_EXTENSION) === 'part')
{
return true;
}
return false;
}
/**
* walk over any folders that are not fully scanned yet and scan them
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment