Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
irods-microservices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
RDM Infrastructure
irods-microservices
Commits
31f9bf77
Commit
31f9bf77
authored
3 years ago
by
Felix A. Croes
Browse files
Options
Downloads
Patches
Plain Diff
Let msiArchiveExtract also restore attributes.
parent
21db28c2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/msiArchiveExtract.cc
+59
-17
59 additions, 17 deletions
src/msiArchiveExtract.cc
with
59 additions
and
17 deletions
src/msiArchiveExtract.cc
+
59
−
17
View file @
31f9bf77
...
...
@@ -9,6 +9,7 @@
#include
"irods_includes.hh"
#include
"Archive.hh"
#include
"rsModDataObjMeta.hpp"
#include
"rsModAVUMetadata.hpp"
#include
<string>
#include
<fstream>
...
...
@@ -16,6 +17,53 @@
#include
<sstream>
#include
<iomanip>
static
void
modify
(
rsComm_t
*
rsComm
,
std
::
string
file
,
json_t
*
json
)
{
modDataObjMeta_t
modDataObj
;
dataObjInfo_t
dataObjInfo
;
keyValPair_t
regParam
;
char
tmpStr
[
MAX_NAME_LEN
];
json_int_t
modified
;
memset
(
&
modDataObj
,
'\0'
,
sizeof
(
modDataObjMeta_t
));
memset
(
&
dataObjInfo
,
'\0'
,
sizeof
(
dataObjInfo_t
));
memset
(
&
regParam
,
'\0'
,
sizeof
(
keyValPair_t
));
rstrcpy
(
dataObjInfo
.
objPath
,
file
.
c_str
(),
MAX_NAME_LEN
);
modDataObj
.
dataObjInfo
=
&
dataObjInfo
;
modified
=
json_integer_value
(
json_object_get
(
json
,
"modified"
));
snprintf
(
tmpStr
,
MAX_NAME_LEN
,
"%lld"
,
modified
);
addKeyVal
(
&
regParam
,
DATA_MODIFY_KW
,
tmpStr
);
modDataObj
.
regParam
=
&
regParam
;
rsModDataObjMeta
(
rsComm
,
&
modDataObj
);
}
static
void
attributes
(
rsComm_t
*
rsComm
,
std
::
string
file
,
const
char
*
type
,
json_t
*
list
)
{
modAVUMetadataInp_t
modAVUInp
;
size_t
sz
,
i
;
const
char
*
name
;
json_t
*
json
;
memset
(
&
modAVUInp
,
'\0'
,
sizeof
(
modAVUMetadataInp_t
));
modAVUInp
.
arg1
=
(
char
*
)
type
;
modAVUInp
.
arg2
=
(
char
*
)
file
.
c_str
();
name
=
NULL
;
sz
=
json_array_size
(
list
);
for
(
i
=
0
;
i
<
sz
;
i
++
)
{
json
=
json_array_get
(
list
,
i
);
name
=
json_string_value
(
json_object_get
(
json
,
"name"
));
modAVUInp
.
arg3
=
(
char
*
)
json_string_value
(
json_object_get
(
json
,
"name"
));
modAVUInp
.
arg4
=
(
char
*
)
json_string_value
(
json_object_get
(
json
,
"value"
));
modAVUInp
.
arg5
=
(
char
*
)
json_string_value
(
json_object_get
(
json
,
"unit"
));
modAVUInp
.
arg0
=
(
strcmp
(
modAVUInp
.
arg3
,
name
)
==
0
)
?
(
char
*
)
"add"
:
(
char
*
)
"set"
;
name
=
modAVUInp
.
arg3
;
rsModAVUMetadata
(
rsComm
,
&
modAVUInp
);
}
}
extern
"C"
{
int
msiArchiveExtract
(
msParam_t
*
archiveIn
,
...
...
@@ -44,27 +92,21 @@ extern "C" {
Archive
*
a
=
Archive
::
open
(
rei
->
rsComm
,
archive
);
while
((
json
=
a
->
nextItem
())
!=
NULL
)
{
std
::
string
file
;
json_t
*
list
;
file
=
path
+
"/"
+
json_string_value
(
json_object_get
(
json
,
"name"
));
a
->
extractItem
(
file
);
list
=
json_object_get
(
json
,
"attributes"
);
if
(
strcmp
(
json_string_value
(
json_object_get
(
json
,
"type"
)),
"dataObj"
)
==
0
)
{
modDataObjMeta_t
modDataObj
;
dataObjInfo_t
dataObjInfo
;
keyValPair_t
regParam
;
char
tmpStr
[
MAX_NAME_LEN
];
json_int_t
modified
;
memset
(
&
modDataObj
,
'\0'
,
sizeof
(
modDataObjMeta_t
));
memset
(
&
dataObjInfo
,
'\0'
,
sizeof
(
dataObjInfo_t
));
memset
(
&
regParam
,
'\0'
,
sizeof
(
keyValPair_t
));
rstrcpy
(
dataObjInfo
.
objPath
,
file
.
c_str
(),
MAX_NAME_LEN
);
modDataObj
.
dataObjInfo
=
&
dataObjInfo
;
modified
=
json_integer_value
(
json_object_get
(
json
,
"modified"
));
snprintf
(
tmpStr
,
MAX_NAME_LEN
,
"%lld"
,
modified
);
addKeyVal
(
&
regParam
,
DATA_MODIFY_KW
,
tmpStr
);
modDataObj
.
regParam
=
&
regParam
;
rsModDataObjMeta
(
rei
->
rsComm
,
&
modDataObj
);
if
(
strcmp
(
json_string_value
(
json_object_get
(
json
,
"type"
)),
"coll"
)
==
0
)
{
if
(
list
!=
NULL
)
{
attributes
(
rei
->
rsComm
,
file
,
"-C"
,
list
);
}
}
else
{
modify
(
rei
->
rsComm
,
file
,
json
);
if
(
list
!=
NULL
)
{
attributes
(
rei
->
rsComm
,
file
,
"-d"
,
list
);
}
}
}
delete
a
;
...
...
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