q.rm <- function(jid=NULL, type=NULL, force=FALSE)
# delete job queue by jid number
# 1. add protection to not to delete job
# under schedule.
{
check.force.condition.del <- function(file)
{
# protecting important directory, not to delete
if(!force)
{
SAVED.DIR <- sprintf('%s/schedule', q.wd() )
DIR <- dirname(file)
if(DIR == SAVED.DIR) return(NULL)
}
file.remove(file)
message(file, ' - [removed]')
}
if(!is.null(jid))
jid <- basename(jid) else jid <- '*'
find.and.del <- function(name)
{
if(name == 'schedule' && !force)
{
warning('schedule job is only allowed to delete by force=TRUE')
return(NULL)
}
# read log dir structure, delete file
FPATH <- sprintf("%s/%s", q.wd(), name)
FLIST <- list.files(path = FPATH,
recursive = TRUE,
full.names = TRUE,
pattern = jid)
if(length(FLIST) > 0 )
{
for(item in FLIST )
{
# protection on schedule directory
check.force.condition.del(file=item)
}
}
}
if(is.null(type) && jid == "*")
{
# all types
find.and.del('scripts')
find.and.del('failed')
find.and.del('inbox')
find.and.del('outbox')
find.and.del('output')
find.and.del('progress')
if(force)
{
find.and.del('agent')
system(sprintf('rm -fr %s/agent/id.*', q.wd() ))
find.and.del('schedule')
}
} else
find.and.del(name=type) # only type
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.