Merge pull request #389 from sasiflo/dev_sasiflo_sync
Synchronization: Directory creation on sync import corrected.
This commit is contained in:
commit
9a64c6b9f7
@ -194,7 +194,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
* @return null|string ETag
|
* @return null|string ETag
|
||||||
*/
|
*/
|
||||||
public function createFile($name, $data = null) {
|
public function createFile($name, $data = null) {
|
||||||
logger($name, LOGGER_DEBUG);
|
logger('create file in directory ' . $name, LOGGER_DEBUG);
|
||||||
|
|
||||||
if (! $this->auth->owner_id) {
|
if (! $this->auth->owner_id) {
|
||||||
logger('permission denied ' . $name);
|
logger('permission denied ' . $name);
|
||||||
@ -358,7 +358,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function createDirectory($name) {
|
public function createDirectory($name) {
|
||||||
logger($name, LOGGER_DEBUG);
|
logger('create directory ' . $name, LOGGER_DEBUG);
|
||||||
|
|
||||||
if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) {
|
if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) {
|
||||||
throw new DAV\Exception\Forbidden('Permission denied.');
|
throw new DAV\Exception\Forbidden('Permission denied.');
|
||||||
@ -372,7 +372,9 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
|||||||
$result = attach_mkdir($r[0], $this->auth->observer, array('filename' => $name, 'folder' => $this->folder_hash));
|
$result = attach_mkdir($r[0], $this->auth->observer, array('filename' => $name, 'folder' => $this->folder_hash));
|
||||||
|
|
||||||
if($result['success']) {
|
if($result['success']) {
|
||||||
$sync = attach_export_data($r[0],$ret['data']['hash']);
|
$sync = attach_export_data($r[0],$result['data']['hash']);
|
||||||
|
logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
if($sync) {
|
if($sync) {
|
||||||
build_sync_packet($r[0]['channel_id'],array('file' => array($sync)));
|
build_sync_packet($r[0]['channel_id'],array('file' => array($sync)));
|
||||||
}
|
}
|
||||||
|
@ -973,8 +973,11 @@ function sync_files($channel,$files) {
|
|||||||
|
|
||||||
$attach_exists = false;
|
$attach_exists = false;
|
||||||
$x = attach_by_hash($att['hash']);
|
$x = attach_by_hash($att['hash']);
|
||||||
|
logger('sync_files duplicate check: attach_exists=' . $attach_exists, LOGGER_DEBUG);
|
||||||
|
logger('sync_files duplicate check: att=' . print_r($att,true), LOGGER_DEBUG);
|
||||||
|
logger('sync_files duplicate check: attach_by_hash() returned ' . print_r($x,true), LOGGER_DEBUG);
|
||||||
|
|
||||||
if($x) {
|
if($x['success']) {
|
||||||
$attach_exists = true;
|
$attach_exists = true;
|
||||||
$attach_id = $x[0]['id'];
|
$attach_id = $x[0]['id'];
|
||||||
}
|
}
|
||||||
@ -1043,15 +1046,17 @@ function sync_files($channel,$files) {
|
|||||||
|
|
||||||
|
|
||||||
if($attach_exists) {
|
if($attach_exists) {
|
||||||
$str = '';
|
logger('sync_files attach exists: ' . print_r($att,true), LOGGER_DEBUG);
|
||||||
foreach($att as $k => $v) {
|
$str = '';
|
||||||
if($str)
|
foreach($att as $k => $v) {
|
||||||
$str .= ",";
|
if($str)
|
||||||
$str .= " `" . $k . "` = '" . $v . "' ";
|
$str .= ",";
|
||||||
}
|
$str .= " `" . $k . "` = '" . $v . "' ";
|
||||||
$r = dbq("update `attach` set " . $str . " where id = " . intval($attach_id) );
|
}
|
||||||
|
$r = dbq("update `attach` set " . $str . " where id = " . intval($attach_id) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
logger('sync_files attach does not exists: ' . print_r($att,true), LOGGER_DEBUG);
|
||||||
$r = dbq("INSERT INTO attach (`"
|
$r = dbq("INSERT INTO attach (`"
|
||||||
. implode("`, `", array_keys($att))
|
. implode("`, `", array_keys($att))
|
||||||
. "`) VALUES ('"
|
. "`) VALUES ('"
|
||||||
@ -1064,6 +1069,7 @@ function sync_files($channel,$files) {
|
|||||||
|
|
||||||
if($att['filetype'] === 'multipart/mixed' && $att['is_dir']) {
|
if($att['filetype'] === 'multipart/mixed' && $att['is_dir']) {
|
||||||
os_mkdir($newfname, STORAGE_DEFAULT_PERMISSIONS,true);
|
os_mkdir($newfname, STORAGE_DEFAULT_PERMISSIONS,true);
|
||||||
|
$attachment_stored = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user