summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2011-08-15 20:33:02 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2011-08-15 20:33:02 -0400
commit5fbed936bffa1dc06e5356a89f079fe27aa624b2 (patch)
tree6003fba7049c36132130c620a7c6e1da8b7ba911
parent1ec75330ecf342ef38092934294a6a444bbbdac7 (diff)
downloadnextcloud-server-5fbed936bffa1dc06e5356a89f079fe27aa624b2.tar.gz
nextcloud-server-5fbed936bffa1dc06e5356a89f079fe27aa624b2.zip
Automatic creation of 'Shared' directory, bug fixes for an empty 'Shared' directory
-rw-r--r--apps/files_sharing/lib_share.php2
-rw-r--r--apps/files_sharing/sharedstorage.php42
-rw-r--r--lib/util.php4
3 files changed, 27 insertions, 21 deletions
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index b87775dd8c5..a42fed3e763 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -59,7 +59,7 @@ class OC_Share {
throw new Exception("This item is already shared with ".$uid);
}
// Check if the target already exists for the user, if it does append a number to the name
- $target = "/".$uid."/files/Share/".basename($source);
+ $target = "/".$uid."/files/Shared/".basename($source);
if (self::getSource($target)) {
if ($pos = strrpos($target, ".")) {
$name = substr($target, 0, $pos);
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 11b141373c4..55254ccd662 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -32,6 +32,9 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function __construct($arguments) {
$this->datadir = $arguments['datadir'];
+ if (!OC_Filesystem::is_dir($this->datadir)) {
+ OC_Filesystem::mkdir($this->datadir);
+ }
}
public function getInternalPath($path) {
@@ -309,14 +312,15 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function filectime($path) {
if ($path == "" || $path == "/") {
$ctime = 0;
- $dir = $this->opendir($path);
- while (($filename = readdir($dir)) != false) {
- $tempctime = $this->filectime($filename);
- if ($tempctime < $ctime) {
- $ctime = $tempctime;
+ if ($dh = $this->opendir($path)) {
+ while (($filename = readdir($dh)) !== false) {
+ $tempctime = $this->filectime($filename);
+ if ($tempctime < $ctime) {
+ $ctime = $tempctime;
+ }
}
+ return $ctime;
}
- return $ctime;
} else {
$source = $this->getSource($path);
if ($source) {
@@ -329,14 +333,15 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function filemtime($path) {
if ($path == "" || $path == "/") {
$mtime = 0;
- $dir = $this->opendir($path);
- while (($filename = readdir($dir)) != false) {
- $tempmtime = $this->filemtime($filename);
- if ($tempmtime > $mtime) {
- $mtime = $tempmtime;
+ if ($dh = $this->opendir($path)) {
+ while (($filename = readdir($dh)) !== false) {
+ $tempmtime = $this->filemtime($filename);
+ if ($tempmtime > $mtime) {
+ $mtime = $tempmtime;
+ }
}
+ return $mtime;
}
- return $mtime;
} else {
$source = $this->getSource($path);
if ($source) {
@@ -349,14 +354,15 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function fileatime($path) {
if ($path == "" || $path == "/") {
$atime = 0;
- $dir = $this->opendir($path);
- while (($filename = readdir($dir)) != false) {
- $tempatime = $this->fileatime($filename);
- if ($tempatime > $atime) {
- $atime = $tempatime;
+ if ($dh = $this->opendir($path)) {
+ while (($filename = readdir($dh)) !== false) {
+ $tempatime = $this->fileatime($filename);
+ if ($tempatime > $atime) {
+ $atime = $tempatime;
+ }
}
+ return $atime;
}
- return $atime;
} else {
$source = $this->getSource($path);
if ($source) {
diff --git a/lib/util.php b/lib/util.php
index 53c4283be11..4b49d1319b9 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -54,8 +54,8 @@ class OC_Util {
OC_Filesystem::mount($rootStorage,'/');
// TODO add this storage provider in a proper way
- $sharedStorage = OC_Filesystem::createStorage('shared',array('datadir'=>'/'.OC_User::getUser().'/files/Share/'));
- OC_Filesystem::mount($sharedStorage,'/'.OC_User::getUser().'/files/Share/');
+ $sharedStorage = OC_Filesystem::createStorage('shared',array('datadir'=>'/'.OC_User::getUser().'/files/Shared/'));
+ OC_Filesystem::mount($sharedStorage,'/'.OC_User::getUser().'/files/Shared/');
$CONFIG_DATADIRECTORY = "$CONFIG_DATADIRECTORY_ROOT/$user/$root";
if( !is_dir( $CONFIG_DATADIRECTORY )){