diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2013-02-10 06:38:31 -0800 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2013-02-10 06:38:31 -0800 |
commit | d08a3bb46e01a61c9ac9889e700f82eaf63fd1f1 (patch) | |
tree | 508f1cdb09a84fabe9bfde7803f5ed4880536912 | |
parent | 72a33e01e6600aaeb786527109b1e29886276aea (diff) | |
parent | 1263511a179fb1508f41207d61d76739e087b239 (diff) | |
download | nextcloud-server-d08a3bb46e01a61c9ac9889e700f82eaf63fd1f1.tar.gz nextcloud-server-d08a3bb46e01a61c9ac9889e700f82eaf63fd1f1.zip |
Merge pull request #1590 from owncloud/fix_470
append .part to put files
-rw-r--r-- | lib/connector/sabre/file.php | 8 | ||||
-rw-r--r-- | lib/files/cache/scanner.php | 18 |
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index 1c18a391742..521c5f0571d 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -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); } diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index 9a5546dce3f..5a9a119458e 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -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) { @@ -133,6 +133,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 |