summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/storage/common.php4
-rw-r--r--lib/private/files/storage/local.php2
-rw-r--r--lib/private/files/storage/polyfill/copydirectory.php2
-rw-r--r--lib/private/files/view.php99
-rw-r--r--lib/private/util.php2
5 files changed, 61 insertions, 48 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index a5ed5fd3996..2d579fa2b60 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -260,7 +260,7 @@ abstract class Common implements Storage {
$dh = $this->opendir($path);
if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
- if ($file !== '.' and $file !== '..') {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if ($this->is_dir($path . '/' . $file)) {
mkdir($target . '/' . $file);
$this->addLocalFolder($path . '/' . $file, $target . '/' . $file);
@@ -283,7 +283,7 @@ abstract class Common implements Storage {
$dh = $this->opendir($dir);
if (is_resource($dh)) {
while (($item = readdir($dh)) !== false) {
- if ($item == '.' || $item == '..') continue;
+ if (\OC\Files\Filesystem::isIgnoredDir($item)) continue;
if (strstr(strtolower($item), strtolower($query)) !== false) {
$files[] = $dir . '/' . $item;
}
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index 3676fe69131..4b6b08a16fd 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -283,7 +283,7 @@ class Local extends \OC\Files\Storage\Common {
$files = array();
$physicalDir = $this->getSourcePath($dir);
foreach (scandir($physicalDir) as $item) {
- if ($item == '.' || $item == '..')
+ if (\OC\Files\Filesystem::isIgnoredDir($item))
continue;
$physicalItem = $physicalDir . '/' . $item;
diff --git a/lib/private/files/storage/polyfill/copydirectory.php b/lib/private/files/storage/polyfill/copydirectory.php
index 1b4873a3a76..73c6d3d5436 100644
--- a/lib/private/files/storage/polyfill/copydirectory.php
+++ b/lib/private/files/storage/polyfill/copydirectory.php
@@ -72,7 +72,7 @@ trait CopyDirectory {
$dh = $this->opendir($source);
$result = true;
while ($file = readdir($dh)) {
- if ($file !== '.' and $file !== '..') {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if ($this->is_dir($source . '/' . $file)) {
$this->mkdir($target . '/' . $file);
$result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file);
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 9afa9d40b20..f92441492f7 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -759,59 +759,72 @@ class View {
$this->lockFile($path2, ILockingProvider::LOCK_SHARED);
$this->lockFile($path1, ILockingProvider::LOCK_SHARED);
+ $lockTypePath1 = ILockingProvider::LOCK_SHARED;
+ $lockTypePath2 = ILockingProvider::LOCK_SHARED;
- $exists = $this->file_exists($path2);
- if ($this->shouldEmitHooks()) {
- \OC_Hook::emit(
- Filesystem::CLASSNAME,
- Filesystem::signal_copy,
- array(
- Filesystem::signal_param_oldpath => $this->getHookPath($path1),
- Filesystem::signal_param_newpath => $this->getHookPath($path2),
- Filesystem::signal_param_run => &$run
- )
- );
- $this->emit_file_hooks_pre($exists, $path2, $run);
- }
- if ($run) {
- $mount1 = $this->getMount($path1);
- $mount2 = $this->getMount($path2);
- $storage1 = $mount1->getStorage();
- $internalPath1 = $mount1->getInternalPath($absolutePath1);
- $storage2 = $mount2->getStorage();
- $internalPath2 = $mount2->getInternalPath($absolutePath2);
-
- $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE);
-
- if ($mount1->getMountPoint() == $mount2->getMountPoint()) {
- if ($storage1) {
- $result = $storage1->copy($internalPath1, $internalPath2);
- } else {
- $result = false;
- }
- } else {
- $result = $storage2->copyFromStorage($storage1, $internalPath1, $internalPath2);
- }
-
- $this->updater->update($path2);
-
- $this->changeLock($path2, ILockingProvider::LOCK_SHARED);
+ try {
- if ($this->shouldEmitHooks() && $result !== false) {
+ $exists = $this->file_exists($path2);
+ if ($this->shouldEmitHooks()) {
\OC_Hook::emit(
Filesystem::CLASSNAME,
- Filesystem::signal_post_copy,
+ Filesystem::signal_copy,
array(
Filesystem::signal_param_oldpath => $this->getHookPath($path1),
- Filesystem::signal_param_newpath => $this->getHookPath($path2)
+ Filesystem::signal_param_newpath => $this->getHookPath($path2),
+ Filesystem::signal_param_run => &$run
)
);
- $this->emit_file_hooks_post($exists, $path2);
+ $this->emit_file_hooks_pre($exists, $path2, $run);
}
+ if ($run) {
+ $mount1 = $this->getMount($path1);
+ $mount2 = $this->getMount($path2);
+ $storage1 = $mount1->getStorage();
+ $internalPath1 = $mount1->getInternalPath($absolutePath1);
+ $storage2 = $mount2->getStorage();
+ $internalPath2 = $mount2->getInternalPath($absolutePath2);
+
+ $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE);
+ $lockTypePath2 = ILockingProvider::LOCK_EXCLUSIVE;
+
+ if ($mount1->getMountPoint() == $mount2->getMountPoint()) {
+ if ($storage1) {
+ $result = $storage1->copy($internalPath1, $internalPath2);
+ } else {
+ $result = false;
+ }
+ } else {
+ $result = $storage2->copyFromStorage($storage1, $internalPath1, $internalPath2);
+ }
- $this->unlockFile($path2, ILockingProvider::LOCK_SHARED);
- $this->unlockFile($path1, ILockingProvider::LOCK_SHARED);
+ $this->updater->update($path2);
+
+ $this->changeLock($path2, ILockingProvider::LOCK_SHARED);
+ $lockTypePath2 = ILockingProvider::LOCK_SHARED;
+
+ if ($this->shouldEmitHooks() && $result !== false) {
+ \OC_Hook::emit(
+ Filesystem::CLASSNAME,
+ Filesystem::signal_post_copy,
+ array(
+ Filesystem::signal_param_oldpath => $this->getHookPath($path1),
+ Filesystem::signal_param_newpath => $this->getHookPath($path2)
+ )
+ );
+ $this->emit_file_hooks_post($exists, $path2);
+ }
+
+ }
+ } catch (\Exception $e) {
+ $this->unlockFile($path2, $lockTypePath2);
+ $this->unlockFile($path1, $lockTypePath1);
+ throw $e;
}
+
+ $this->unlockFile($path2, $lockTypePath2);
+ $this->unlockFile($path1, $lockTypePath1);
+
}
return $result;
}
@@ -1656,7 +1669,7 @@ class View {
if ($trimmed === '') {
throw new InvalidPathException($l10n->t('Empty filename is not allowed'));
}
- if ($trimmed === '.' || $trimmed === '..') {
+ if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
throw new InvalidPathException($l10n->t('Dot files are not allowed'));
}
diff --git a/lib/private/util.php b/lib/private/util.php
index eb1de5be5a4..667d358655f 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -1433,7 +1433,7 @@ class OC_Util {
if ($trimmed === '') {
return false;
}
- if ($trimmed === '.' || $trimmed === '..') {
+ if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
return false;
}
foreach (str_split($trimmed) as $char) {