Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
db566e3c
Commit
db566e3c
authored
3 years ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Allow the metadata property to be set with add() and update()
Sorry for the impending imminent merge hassle Deuce!
parent
db4cdac2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/js_filebase.c
+19
-5
19 additions, 5 deletions
src/sbbs3/js_filebase.c
with
19 additions
and
5 deletions
src/sbbs3/js_filebase.c
+
19
−
5
View file @
db566e3c
...
...
@@ -368,7 +368,7 @@ parse_file_index_properties(JSContext *cx, JSObject* obj, fileidxrec_t* idx)
}
static
int
parse_file_properties
(
JSContext
*
cx
,
JSObject
*
obj
,
file_t
*
file
,
char
**
extdesc
)
parse_file_properties
(
JSContext
*
cx
,
JSObject
*
obj
,
file_t
*
file
,
char
**
extdesc
,
char
**
metadata
)
{
char
*
cp
=
NULL
;
size_t
cp_sz
=
0
;
...
...
@@ -536,6 +536,18 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
}
truncsp
(
*
extdesc
);
}
prop_name
=
"metadata"
;
if
(
metadata
!=
NULL
&&
JS_GetProperty
(
cx
,
obj
,
prop_name
,
&
val
)
&&
!
JSVAL_NULL_OR_VOID
(
val
))
{
FREE_AND_NULL
(
*
metadata
);
JSVALUE_TO_MSTRING
(
cx
,
val
,
*
metadata
,
NULL
);
HANDLE_PENDING
(
cx
,
*
metadata
);
if
(
*
metadata
==
NULL
)
{
free
(
cp
);
JS_ReportError
(
cx
,
"Invalid '%s' string in file object"
,
prop_name
);
return
SMB_ERR_MEM
;
}
truncsp
(
*
metadata
);
}
prop_name
=
"tags"
;
if
(
JS_GetProperty
(
cx
,
obj
,
prop_name
,
&
val
)
&&
!
JSVAL_NULL_OR_VOID
(
val
))
{
JSVALUE_TO_RASTRING
(
cx
,
val
,
cp
,
&
cp_sz
,
NULL
);
...
...
@@ -1117,6 +1129,7 @@ js_add_file(JSContext *cx, uintN argc, jsval *arglist)
jsval
*
argv
=
JS_ARGV
(
cx
,
arglist
);
private_t
*
p
;
char
*
extdesc
=
NULL
;
char
*
metadata
=
NULL
;
file_t
file
;
client_t
*
client
=
NULL
;
bool
use_diz_always
=
false
;
...
...
@@ -1141,7 +1154,7 @@ js_add_file(JSContext *cx, uintN argc, jsval *arglist)
uintN
argn
=
0
;
if
(
argn
<
argc
&&
JSVAL_IS_OBJECT
(
argv
[
argn
]))
{
p
->
smb_result
=
parse_file_properties
(
cx
,
JSVAL_TO_OBJECT
(
argv
[
argn
]),
&
file
,
&
extdesc
);
p
->
smb_result
=
parse_file_properties
(
cx
,
JSVAL_TO_OBJECT
(
argv
[
argn
]),
&
file
,
&
extdesc
,
&
metadata
);
if
(
p
->
smb_result
!=
SMB_SUCCESS
)
return
JS_TRUE
;
argn
++
;
...
...
@@ -1170,7 +1183,7 @@ js_add_file(JSContext *cx, uintN argc, jsval *arglist)
getfilepath
(
scfg
,
&
file
,
fpath
);
if
(
file
.
from_ip
==
NULL
)
file_client_hfields
(
&
file
,
client
);
p
->
smb_result
=
smb_addfile
(
&
p
->
smb
,
&
file
,
SMB_SELFPACK
,
extdesc
,
/* contents: */
NULL
,
fpath
);
p
->
smb_result
=
smb_addfile
(
&
p
->
smb
,
&
file
,
SMB_SELFPACK
,
extdesc
,
metadata
,
fpath
);
JS_SET_RVAL
(
cx
,
arglist
,
BOOLEAN_TO_JSVAL
(
p
->
smb_result
==
SMB_SUCCESS
));
}
JS_RESUMEREQUEST
(
cx
,
rc
);
...
...
@@ -1231,10 +1244,11 @@ js_update_file(JSContext *cx, uintN argc, jsval *arglist)
JSBool
result
=
JS_TRUE
;
char
*
extdesc
=
NULL
;
char
*
metadata
=
NULL
;
rc
=
JS_SUSPENDREQUEST
(
cx
);
if
(
filename
!=
NULL
&&
fileobj
!=
NULL
&&
(
p
->
smb_result
=
smb_loadfile
(
&
p
->
smb
,
filename
,
&
file
,
file_detail_extdesc
))
==
SMB_SUCCESS
)
{
p
->
smb_result
=
parse_file_properties
(
cx
,
fileobj
,
&
file
,
&
extdesc
);
p
->
smb_result
=
parse_file_properties
(
cx
,
fileobj
,
&
file
,
&
extdesc
,
&
metadata
);
if
((
extdesc
==
NULL
||
use_diz_always
==
true
)
&&
file
.
dir
<
scfg
->
total_dirs
&&
(
scfg
->
dir
[
file
.
dir
]
->
misc
&
DIR_DIZ
))
{
...
...
@@ -1258,7 +1272,7 @@ js_update_file(JSContext *cx, uintN argc, jsval *arglist)
p
->
smb_result
=
smb_putfile
(
&
p
->
smb
,
&
file
);
else
{
if
((
p
->
smb_result
=
smb_removefile
(
&
p
->
smb
,
&
file
))
==
SMB_SUCCESS
)
{
p
->
smb_result
=
smb_addfile
(
&
p
->
smb
,
&
file
,
SMB_SELFPACK
,
extdesc
,
/* contents: */
NULL
,
newfname
);
p
->
smb_result
=
smb_addfile
(
&
p
->
smb
,
&
file
,
SMB_SELFPACK
,
extdesc
,
metadata
,
newfname
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment