diff options
Diffstat (limited to 'Zotlabs/Storage/Directory.php')
-rw-r--r-- | Zotlabs/Storage/Directory.php | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index ae36fc1c0..1231dfa25 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -3,6 +3,7 @@ namespace Zotlabs\Storage; use Sabre\DAV; +use Zotlabs\Lib\Libsync; /** * @brief RedDirectory class. @@ -179,7 +180,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo if ($ch) { $sync = attach_export_data($ch, $this->folder_hash); if ($sync) - build_sync_packet($ch['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync))); } $this->red_path = $new_path; @@ -280,8 +281,19 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $xpath = attach_syspaths($this->auth->owner_id, $hash); - // returns the number of bytes that were written to the file, or FALSE on failure - $size = file_put_contents($f, $data); + + if (is_resource($data)) { + $fp = fopen($f,'wb'); + if ($fp) { + pipe_streams($data,$fp); + fclose($fp); + } + $size = filesize($f); + } + else { + $size = file_put_contents($f, $data); + } + // delete attach entry if file_put_contents() failed if ($size === false) { logger('file_put_contents() failed to ' . $f); @@ -314,7 +326,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $d = q("UPDATE attach SET filesize = '%s', os_path = '%s', display_path = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d", dbesc($size), dbesc($xpath['os_path']), - dbesc($xpath['display_path']), + dbesc($xpath['path']), intval($is_photo), dbesc($edited), dbesc($hash), @@ -363,12 +375,12 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $p = photo_upload($c[0], \App::get_observer(), $args); } - \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $this->folder_hash ]); + \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $hash ]); $sync = attach_export_data($c[0], $hash); if ($sync) - build_sync_packet($c[0]['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($c[0]['channel_id'], array('file' => array($sync))); } /** @@ -401,7 +413,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG); if($sync) { - build_sync_packet($r[0]['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($r[0]['channel_id'], array('file' => array($sync))); } } else { @@ -432,7 +444,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo if ($ch) { $sync = attach_export_data($ch, $this->folder_hash, true); if ($sync) - build_sync_packet($ch['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync))); } } |