summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-05-24 15:07:23 +0200
committerRobin Appelman <icewind@owncloud.com>2016-06-03 13:30:59 +0200
commit63408fa6ef70fb26ef57d93c24a36e325e788b2b (patch)
treee234a2e91923ee143b0c8feec5857334f75473e5 /lib
parent2d5bee0661d52629b1ca0b8ec3c57752a3b7d8ed (diff)
downloadnextcloud-server-63408fa6ef70fb26ef57d93c24a36e325e788b2b.tar.gz
nextcloud-server-63408fa6ef70fb26ef57d93c24a36e325e788b2b.zip
allow deleting "ghost files" trough the View and Node api
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/View.php43
1 files changed, 28 insertions, 15 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index f738542ea8c..8a99bc609cf 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -337,10 +337,17 @@ class View {
return $this->removeMount($mount, $absolutePath);
}
if ($this->is_dir($path)) {
- return $this->basicOperation('rmdir', $path, array('delete'));
+ $result = $this->basicOperation('rmdir', $path, array('delete'));
} else {
- return false;
+ $result = false;
}
+
+ if (!$result && !$this->file_exists($path)) { //clear ghost files from the cache on delete
+ $storage = $mount->getStorage();
+ $internalPath = $mount->getInternalPath($absolutePath);
+ $storage->getUpdater()->remove($internalPath);
+ }
+ return $result;
}
/**
@@ -429,7 +436,7 @@ class View {
/**
* @param string $path
- * @param int $from
+ * @param int $from
* @param int $to
* @return bool|mixed
* @throws \OCP\Files\InvalidPathException
@@ -441,18 +448,18 @@ class View {
$handle = $this->fopen($path, 'rb');
if ($handle) {
if (fseek($handle, $from) === 0) {
- $chunkSize = 8192; // 8 kB chunks
- $end = $to + 1;
- while (!feof($handle) && ftell($handle) < $end) {
- $len = $end-ftell($handle);
- if ($len > $chunkSize) {
- $len = $chunkSize;
+ $chunkSize = 8192; // 8 kB chunks
+ $end = $to + 1;
+ while (!feof($handle) && ftell($handle) < $end) {
+ $len = $end - ftell($handle);
+ if ($len > $chunkSize) {
+ $len = $chunkSize;
+ }
+ echo fread($handle, $len);
+ flush();
}
- echo fread($handle, $len);
- flush();
- }
- $size = ftell($handle) - $from;
- return $size;
+ $size = ftell($handle) - $from;
+ return $size;
}
throw new \OCP\Files\UnseekableException('fseek error');
@@ -679,7 +686,13 @@ class View {
if ($mount and $mount->getInternalPath($absolutePath) === '') {
return $this->removeMount($mount, $absolutePath);
}
- return $this->basicOperation('unlink', $path, array('delete'));
+ $result = $this->basicOperation('unlink', $path, array('delete'));
+ if (!$result && !$this->file_exists($path)) { //clear ghost files from the cache on delete
+ $storage = $mount->getStorage();
+ $internalPath = $mount->getInternalPath($absolutePath);
+ $storage->getUpdater()->remove($internalPath);
+ }
+ return $result;
}
/**