aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-06-27 16:36:30 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-06-27 16:36:30 -0700
commit8d84472b4cb85b50c314491e0706d80eb5b7de6d (patch)
tree1c442f5ccb5b9b11dc2108e0da87be240562926f /include
parentb43c0bc471fa7a9afa7e735d1cf0e209372a3477 (diff)
downloadvolse-hubzilla-8d84472b4cb85b50c314491e0706d80eb5b7de6d.tar.gz
volse-hubzilla-8d84472b4cb85b50c314491e0706d80eb5b7de6d.tar.bz2
volse-hubzilla-8d84472b4cb85b50c314491e0706d80eb5b7de6d.zip
bring single instance file storage to dav and cloud uploaded photos
Diffstat (limited to 'include')
-rw-r--r--include/RedDAV/RedDirectory.php12
-rw-r--r--include/RedDAV/RedFile.php24
2 files changed, 28 insertions, 8 deletions
diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php
index c41056ac9..1f7ba8927 100644
--- a/include/RedDAV/RedDirectory.php
+++ b/include/RedDAV/RedDirectory.php
@@ -297,8 +297,18 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
}
if($is_photo) {
+ $album = '';
+ if($this->folder_hash) {
+ $f1 = q("select filename from attach WHERE hash = '%s' AND uid = %d",
+ dbesc($this->folder_hash),
+ intval($c[0]['channel_id'])
+ );
+ if($f1)
+ $album = $f1[0]['filename'];
+ }
+
require_once('include/photos.php');
- $args = array( 'data' => @file_get_contents($f), 'resource_id' => $hash);
+ $args = array( 'resource_id' => $hash, 'album' => $album, 'os_path' => $f, 'filename' => $name, 'getimagesize' => $x);
$p = photo_upload($c[0],get_app()->get_observer(),$args);
}
diff --git a/include/RedDAV/RedFile.php b/include/RedDAV/RedFile.php
index 156acde4a..e4f9c21b9 100644
--- a/include/RedDAV/RedFile.php
+++ b/include/RedDAV/RedFile.php
@@ -102,18 +102,27 @@ class RedFile extends DAV\Node implements DAV\IFile {
);
$is_photo = false;
+ $album = '';
- $r = q("SELECT flags, folder, os_storage, is_photo FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
+ $r = q("SELECT flags, folder, os_storage, filename, is_photo FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
dbesc($this->data['hash']),
intval($c[0]['channel_id'])
);
if ($r) {
if (intval($r[0]['os_storage'])) {
- $d = q("select data from attach where hash = '%s' and uid = %d limit 1",
+ $d = q("select folder, data from attach where hash = '%s' and uid = %d limit 1",
dbesc($this->data['hash']),
intval($c[0]['channel_id'])
);
- if($d) {
+ if($d) {
+ if($d[0]['folder']) {
+ $f1 = q("select filename from attach where is_dir = 1 and hash = '%s' and uid = %d limit 1",
+ dbesc($d[0]['folder']),
+ intval($c[0]['channel_id'])
+ );
+ if($f1)
+ $album = $f1[0]['filename'];
+ }
$fname = dbunescbin($d[0]['data']);
$f = 'store/' . $this->auth->owner_nick . '/' . (($fname) ? $fname : '');
// @todo check return value and set $size directly
@@ -121,13 +130,14 @@ class RedFile extends DAV\Node implements DAV\IFile {
$size = @filesize($f);
logger('filename: ' . $f . ' size: ' . $size, LOGGER_DEBUG);
}
- $x = @getimagesize($f);
- logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
- if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
+ $gis = @getimagesize($f);
+ logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
+ if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
$is_photo = 1;
}
}
else {
+ // this shouldn't happen any more
$r = q("UPDATE attach SET data = '%s' WHERE hash = '%s' AND uid = %d",
dbescbin(stream_get_contents($data)),
dbesc($this->data['hash']),
@@ -155,7 +165,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
);
if($is_photo) {
- $args = array( 'data' => @file_get_contents($fname), 'resource_id' => $this->data['hash']);
+ $args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_path' => $f, 'filename' => $r[0]['filename'], 'getimagesize' => $gis );
$p = photo_upload($c[0],$this->auth->observer,$args);
}