make /cloud work again after all the shuffling this morning

This commit is contained in:
redmatrix 2015-07-30 18:34:30 -07:00
parent ec41899328
commit fd947c205b
3 changed files with 14 additions and 9 deletions

View File

@ -50,7 +50,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
*/ */
public function __construct($ext_path, &$auth_plugin) { public function __construct($ext_path, &$auth_plugin) {
// $ext_path = urldecode($ext_path); // $ext_path = urldecode($ext_path);
//logger('directory ' . $ext_path, LOGGER_DATA); logger('directory ' . $ext_path, LOGGER_DATA);
$this->ext_path = $ext_path; $this->ext_path = $ext_path;
// remove "/cloud" from the beginning of the path // remove "/cloud" from the beginning of the path
$modulename = get_app()->module; $modulename = get_app()->module;
@ -80,7 +80,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @return array \Sabre\DAV\INode[] * @return array \Sabre\DAV\INode[]
*/ */
public function getChildren() { public function getChildren() {
//logger('children for ' . $this->ext_path, LOGGER_DATA); logger('children for ' . $this->ext_path, LOGGER_DATA);
$this->log(); $this->log();
if (get_config('system', 'block_public') && (! $this->auth->channel_id) && (! $this->auth->observer)) { if (get_config('system', 'block_public') && (! $this->auth->channel_id) && (! $this->auth->observer)) {
@ -370,15 +370,14 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @return void * @return void
*/ */
function getDir() { function getDir() {
//logger($this->ext_path, LOGGER_DEBUG);
logger('GetDir: ' . $this->ext_path, LOGGER_DEBUG);
$this->auth->log(); $this->auth->log();
$modulename = get_app()->module; $modulename = get_app()->module;
$file = $this->ext_path; $file = $this->ext_path;
$x = strpos($file, '/' . $modulename); $x = strpos($file, '/' . $modulename);
if ($x === false)
return;
if ($x === 0) { if ($x === 0) {
$file = substr($file, strlen($modulename) + 1); $file = substr($file, strlen($modulename) + 1);
} }
@ -419,7 +418,6 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
dbesc($path_arr[$x]), dbesc($path_arr[$x]),
intval($channel_id) intval($channel_id)
); );
if ($r && intval($r[0]['is_dir'])) { if ($r && intval($r[0]['is_dir'])) {
$folder = $r[0]['hash']; $folder = $r[0]['hash'];
if (strlen($os_path)) if (strlen($os_path))

View File

@ -49,7 +49,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
$this->data = $data; $this->data = $data;
$this->auth = $auth; $this->auth = $auth;
//logger(print_r($this->data, true), LOGGER_DATA); logger(print_r($this->data, true), LOGGER_DATA);
} }
/** /**
@ -207,6 +207,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
*/ */
public function get() { public function get() {
logger('get file ' . basename($this->name), LOGGER_DEBUG); logger('get file ' . basename($this->name), LOGGER_DEBUG);
logger('os_path: ' . $this->os_path, LOGGER_DATA);
$r = q("SELECT data, flags, os_storage, filename, filetype FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", $r = q("SELECT data, flags, os_storage, filename, filetype FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
dbesc($this->data['hash']), dbesc($this->data['hash']),

View File

@ -196,6 +196,12 @@ function RedFileData($file, &$auth, $test = false) {
if ($x === 0) { if ($x === 0) {
$file = substr($file, 6); $file = substr($file, 6);
} }
else {
$x = strpos($file,'/dav');
if($x === 0)
$file = substr($file,4);
}
if ((! $file) || ($file === '/')) { if ((! $file) || ($file === '/')) {
return new RedDAV\RedDirectory('/', $auth); return new RedDAV\RedDirectory('/', $auth);
@ -244,7 +250,7 @@ function RedFileData($file, &$auth, $test = false) {
$path = $path . '/' . $r[0]['filename']; $path = $path . '/' . $r[0]['filename'];
} }
if (! $r) { if (! $r) {
$r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, created, edited from attach $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
where folder = '%s' and filename = '%s' and uid = %d $perms order by filename limit 1", where folder = '%s' and filename = '%s' and uid = %d $perms order by filename limit 1",
dbesc($folder), dbesc($folder),
dbesc(basename($file)), dbesc(basename($file)),
@ -253,7 +259,7 @@ function RedFileData($file, &$auth, $test = false) {
} }
if (! $r) { if (! $r) {
$errors = true; $errors = true;
$r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, created, edited from attach $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
where folder = '%s' and filename = '%s' and uid = %d order by filename limit 1", where folder = '%s' and filename = '%s' and uid = %d order by filename limit 1",
dbesc($folder), dbesc($folder),
dbesc(basename($file)), dbesc(basename($file)),