Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
irods-rules
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-rules
Commits
4d5c8e6f
Commit
4d5c8e6f
authored
4 years ago
by
Staiger, Christine
Browse files
Options
Downloads
Patches
Plain Diff
Interactive rule for a rods admin to purge the trash and prune empty collections.
parent
989a609f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
interactiveRules/purgeTrashAdmin.r
+55
-0
55 additions, 0 deletions
interactiveRules/purgeTrashAdmin.r
with
55 additions
and
0 deletions
interactiveRules/purgeTrashAdmin.r
0 → 100644
+
55
−
0
View file @
4d5c8e6f
purgeTrashAdmin
{
on
(
userType
(
$
userNameClient
)
==
"rodsadmin"
){
if
(
*
grace
==
0
){
*
grace
=
30
*
24
*
60
*
60
}
msiGetSystemTime
(
*
now
,
*
status
);
*
cutoff
=
int
(
*
now
)
-*
grace
;
*
abspath
=
"/$rodsZoneClient/trash"
writeLine
(
"serverLog"
,
"PURGETRASH: Delete all trashed files older than *cutoff"
);
purgeTrash
(
*
cutoff
,
$
userNameClient
);
}
}
userType
(
*
user
){
foreach
(
*
row
in
SELECT
USER_TYPE
where
USER_NAME
like
"*user"
){
*
type
=*
row.USER_TYPE
;
}
*
type
;
#return value
}
purgeTrash
(
*
cutoff
,
*
user
){
# Purges the trash of all users
*
abspath
=
"/$rodsZoneClient/trash"
foreach
(
*
row
in
SELECT
COLL_NAME
,
DATA_NAME
,
DATA_MODIFY_TIME
where
COLL_NAME
like
"*abspath/%"
){
*
objAccessTime
=
int
(
*
row.DATA_MODIFY_TIME
);
*
coll
=
*
row.COLL_NAME
;
*
obj
=
*
row.DATA_NAME
;
*
path
=
"*coll/*obj"
;
if
(
int
(
*
cutoff
)
>
int
(
*
objAccessTime
)){
writeLine
(
"serverLog"
,
"PURGETRASH: Permanently deleting *path"
);
msiSetACL
(
"default"
,
"admin:own"
,
"*user"
,
"*path"
);
msiDataObjUnlink
(
"*path++++forceFlag="
,
*
status
);
}
writeLine
(
"serverLog"
,
"Check *coll"
);
deleteEmptyColl
(
*
coll
);
}
msiDeleteUnusedAVUs
();
}
deleteEmptyColl
(
*
abspath
){
# Deletes a collection tree if no data objects are stored there.
foreach
(
*
row
in
SELECT
count
(
DATA_NAME
)
where
COLL_NAME
like
"*abspath%"
){
*
count
=
*
row.DATA_NAME
;
}
if
(
int
(
*
count
)
==
int
(
0
)){
writeLine
(
"serverLog"
,
"*abspath: DELETE"
);
msiRmColl
(
*
abspath
,
"irodsAdminRmTrash=++++forceFlag="
,
*
status
);
msiDeleteUnusedAVUs
();
}
}
INPUT
*
grace
=
0
OUTPUT
ruleExecOut
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