diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-03-08 14:22:04 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-07-05 13:03:01 +0200 |
commit | 424ec94680e69a3082a3d3f7c1ceefd7eeae15d2 (patch) | |
tree | 829468c3a7e567f44c2550c252ed52f47618e6fd /lib/helper.php | |
parent | 9c855f7b3d97b312095ba53a08fe45b71ca06c98 (diff) | |
download | nextcloud-server-424ec94680e69a3082a3d3f7c1ceefd7eeae15d2.tar.gz nextcloud-server-424ec94680e69a3082a3d3f7c1ceefd7eeae15d2.zip |
Make buildNotExistingFileName testable and write unittests
Diffstat (limited to 'lib/helper.php')
-rw-r--r-- | lib/helper.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/helper.php b/lib/helper.php index 1860a55fc8f..017221cef77 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -636,6 +636,18 @@ class OC_Helper { * @return string */ public static function buildNotExistingFileName($path, $filename) { + $view = \OC\Files\Filesystem::getView(); + return self::buildNotExistingFileNameForView($path, $filename, $view); + } + + /** + * Adds a suffix to the name in case the file exists + * + * @param $path + * @param $filename + * @return string + */ + public static function buildNotExistingFileNameForView($path, $filename, \OC\Files\View $view) { if($path==='/') { $path=''; } @@ -649,7 +661,7 @@ class OC_Helper { $newpath = $path . '/' . $filename; $counter = 2; - while (\OC\Files\Filesystem::file_exists($newpath)) { + while ($view->file_exists($newpath)) { $newname = $name . ' (' . $counter . ')' . $ext; $newpath = $path . '/' . $newname; $counter++; |