aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-06-17 01:18:55 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-06-17 01:18:55 -0700
commitc6c17182e5c8d48e2ac16039a92df1cf4596fd88 (patch)
tree7fadd90938082b3647d6f626da44a46ec8c1b1fb /include
parent4ecee713d59fc3c5cd58ddcaeca6380b5667f5f3 (diff)
downloadvolse-hubzilla-c6c17182e5c8d48e2ac16039a92df1cf4596fd88.tar.gz
volse-hubzilla-c6c17182e5c8d48e2ac16039a92df1cf4596fd88.tar.bz2
volse-hubzilla-c6c17182e5c8d48e2ac16039a92df1cf4596fd88.zip
attach_mkdirp - implement force option to return success if dir exists
Diffstat (limited to 'include')
-rw-r--r--include/attach.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/attach.php b/include/attach.php
index 76c1064e8..5ad8df502 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -685,13 +685,19 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
// Check for duplicate name.
// Check both the filename and the hash as we will be making use of both.
- $r = q("select hash from attach where ( filename = '%s' or hash = '%s' ) and folder = '%s' and uid = %d limit 1",
+ $r = q("select hash, is_dir, flags from attach where ( filename = '%s' or hash = '%s' ) and folder = '%s' and uid = %d limit 1",
dbesc($arr['filename']),
dbesc($arr['hash']),
dbesc($arr['folder']),
intval($channel['channel_id'])
);
if($r) {
+ if(array_key_exists('force',$arr) && intval($arr['force'])
+ && ( intval($r[0]['is_dir']) || $r[0]['flags'] & ATTACH_FLAG_DIR)) {
+ $ret['success'] = true;
+ $ret['data'] = $r[0];
+ return $ret;
+ }
$ret['message'] = t('duplicate filename or path');
return $ret;
}
@@ -831,7 +837,8 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
continue;
$arx = array(
'filename' => $p,
- 'folder' => $current_parent
+ 'folder' => $current_parent,
+ 'force' => 1
);
if(array_key_exists('allow_cid',$arr))
$arx['allow_cid'] = $arr['allow_cid'];