append .part to put files
This commit is contained in:
parent
1c56539c01
commit
1263511a17
|
@ -45,7 +45,13 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
|
||||||
*/
|
*/
|
||||||
public function put($data) {
|
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);
|
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))) {
|
if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
|
||||||
\OC_DB::beginTransaction();
|
\OC_DB::beginTransaction();
|
||||||
while ($file = readdir($dh)) {
|
while ($file = readdir($dh)) {
|
||||||
if ($file !== '.' and $file !== '..') {
|
if (!$this->isIgnoredFile($file)) {
|
||||||
$child = ($path) ? $path . '/' . $file : $file;
|
$child = ($path) ? $path . '/' . $file : $file;
|
||||||
$data = $this->scanFile($child);
|
$data = $this->scanFile($child);
|
||||||
if ($data) {
|
if ($data) {
|
||||||
|
@ -133,6 +133,22 @@ class Scanner {
|
||||||
}
|
}
|
||||||
return $size;
|
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
|
* walk over any folders that are not fully scanned yet and scan them
|
||||||
|
|
Loading…
Reference in New Issue