various bug fixes

This commit is contained in:
hummypkg 2015-06-22 20:16:48 +00:00
parent 173df12fa7
commit b8833af068
6 changed files with 91 additions and 36 deletions

View File

@ -1,7 +1,7 @@
Package: sweeper
Priority: optional
Section: misc
Version: 2.0.8-4
Version: 2.0.8-5
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif(>=1.2.3-2)

View File

@ -87,6 +87,9 @@ proc ::sweeper::expand {ts str {orig ""}} {
"%channel" [$ts get channel_name] \
"%duration" [$ts duration] \
\
%epname [$ts episode_name] \
%episode [$ts epstr] \
\
"%timestamp" $timestamp \
"%yyyymmdd" $yyyymmdd \
"%hhmm" $hhmm \
@ -740,16 +743,11 @@ proc ::sweeper::clause {folder cmd arg ts} {
######################################################################
proc ::sweeper::runrule {ts rule} {
proc ::sweeper::runrule {ts rule folder} {
log "Processing \[$rule]" 2
if {[string index $rule 0] eq "#" || [llength $rule] < 2} { return 0 }
set folder 0
if {[lindex $rule 0] eq "folder"} {
set folder 1
set rule [lrange $rule 1 end]
}
while {[llength $rule] > 1} {
set rule [lassign $rule cmd arg]
set ret [::sweeper::clause $folder $cmd $arg $ts]
@ -777,7 +775,10 @@ proc ::sweeper::apply {dir cf} {
set runfolder 0
set nrules 0
foreach rule $rules {
if {[lindex $rule 0] eq "folder"} { incr runfolder }
switch -- [lindex $rule 0] {
folder -
global { incr runfolder }
}
if {[string index $rule 0] ne "#" && [llength $rule] > 1} {
incr nrules
}
@ -812,10 +813,13 @@ proc ::sweeper::apply {dir cf} {
}
foreach rule $rules {
if {[lindex $rule 0] eq "folder"} continue
if {[string index $rule 0] eq "#" ||
[llength $rule] < 2} continue
if {[::sweeper::runrule $ts $rule]} break
switch -- [lindex $rule 0] {
folder continue
global { set rule [lrange $rule 1 end] }
}
if {[::sweeper::runrule $ts $rule 0]} break
}
}
@ -840,14 +844,12 @@ proc ::sweeper::apply {dir cf} {
}
set ts 0
foreach de [readdir -nocomplain $entry] {
foreach de [lsort -command [lambda {a b} {
upvar entry e
return $([file mtime "$e/$b"] - [file mtime "$e/$a"])
}] [lsearch -glob -all -inline \
[readdir -nocomplain $entry] {*.ts}]] {
set dentry "$entry/$de"
if {[file isdirectory $dentry]} {
set ts 0
break
}
if {$ts ne "0"} continue
if {![string match {*.ts} $dentry]} continue
log " --- Considering $dentry" 2
@ -876,9 +878,13 @@ proc ::sweeper::apply {dir cf} {
foreach rule $rules {
if {[string index $rule 0] eq "#" ||
[llength $rule] < 2} continue
if {[lindex $rule 0] ne "folder"} continue
if {[::sweeper::runrule $ts $rule]} break
[llength $rule] < 3} continue
switch -- [lindex $rule 0] {
folder -
global { set rule [lrange $rule 1 end] }
default continue
}
if {[::sweeper::runrule $ts $rule 1]} break
}
}

View File

@ -61,10 +61,10 @@ Add pre-defined ruleset:
<fieldset class=rule>
<legend class=comment>
<span class=commentleft>
<span class="ruleicon folder hidden">
<span class="ruleicon folder global hidden">
<img src=/images/711_1_09_Media_Folder.png>
</span>
<span class="ruleicon file hidden">
<span class="ruleicon file global hidden">
<img src=/img/Video_TS_New.png>
</span>
<span class=comment>Unnamed rule</span>
@ -101,6 +101,10 @@ Add pre-defined ruleset:
<div class="foldercomment hidden">
For each sub-folder, inspect a recording within and:
</div>
<div class="globalcomment hidden">
For each recording and sub-folder, inspect a recording
within and:
</div>
<a href=# class=addcriterion>
<img src=img/plus.png
title="Add condition">
@ -164,6 +168,8 @@ For pattern matching, the following special sequences may appear in the pattern:
value='file' checked />Process Files
<input name=newrule_type id=newrule_type_folder type=radio
value='folder' />Process Folders
<input name=newrule_type id=newrule_type_global type=radio
value='global' />Process Files &amp; Folders
<br>
Description:
<input name=newrule_comment id=newrule_comment size=80 maxlength=255 />

View File

@ -96,12 +96,19 @@ proc rule {id rule} {
}
if {$lcomment eq ""} { set lcomment "Unnamed rule" }
if {[lindex $rule 0] eq "folder"} {
switch -- [lindex $rule 0] {
folder {
set type "folder"
set rule [lrange $rule 1 end]
} else {
}
global {
set type "global"
set rule [lrange $rule 1 end]
}
default {
set type "file"
}
}
if {$id > 1} { add_json ",\n" }
add_json " {\n"
@ -135,7 +142,7 @@ proc rule {id rule} {
set arg "continue"
}
}
lassign $arg cmd arg
lassign "$arg" cmd arg
if {$cmd eq "preserve"} { set cmd 'stop' }
add_json " ],\n"
add_json " \"action\": {\n"

View File

@ -467,6 +467,7 @@ var macros = {
var select_file_criteria = {};
var select_folder_criteria = {};
var select_global_criteria = {};
$.each(schema.criterion, function(k, v) {
if (v.deprecated)
return;
@ -478,15 +479,20 @@ $.each(schema.criterion, function(k, v) {
case 'folder':
select_folder_criteria[k] = v.desc;
break;
case 'global':
select_global_criteria[k] = v.desc;
break;
case 'all':
select_file_criteria[k] = v.desc;
select_folder_criteria[k] = v.desc;
select_global_criteria[k] = v.desc;
break;
}
});
var select_file_actions = {};
var select_folder_actions = {};
var select_global_actions = {};
$.each(schema.action, function(k, v) {
if (v.deprecated)
return;
@ -498,9 +504,13 @@ $.each(schema.action, function(k, v) {
case 'folder':
select_folder_actions[k] = v.desc;
break;
case 'global':
select_global_actions[k] = v.desc;
break;
case 'all':
select_file_actions[k] = v.desc;
select_folder_actions[k] = v.desc;
select_global_actions[k] = v.desc;
break;
}
});

View File

@ -6,7 +6,8 @@ function quot(str)
if (!str)
return '""';
if (str.indexOf(" ") == -1 && str.indexOf('"') == -1)
if (str.indexOf(" ") == -1 && str.indexOf('"') == -1
&& str.indexOf("\\") == -1)
return str;
return '{' + str + '}';
}
@ -132,6 +133,8 @@ function ruleconf(rule)
s += '## ';
if (rule.attr('type') == 'folder')
s += 'folder ';
else if (rule.attr('type') == 'global')
s += 'global ';
s += clauseconf(rule);
@ -318,13 +321,20 @@ function addrule(id, data)
.removeClass('hidden');
rule.find('span.comment').html(data.name);
if (data.type == 'folder')
switch (data.type)
{
case 'global':
rule.find('.commentleft > span.global').show();
rule.find('.globalcomment').show();
break;
case 'folder':
rule.find('.commentleft > span.folder').show();
rule.find('.foldercomment').show();
}
else
break;
default:
rule.find('.commentleft > span.file').show();
break;
}
rule.attr('type', data.type);
var $c = rule.find('table.criteria');
@ -725,10 +735,18 @@ function addcriterion(rule, target)
{
var type = rule.attr('type');
if (type == 'folder')
switch (type)
{
case 'folder':
options = select_folder_criteria;
else
break;
case 'global':
options = select_global_criteria;
break;
default:
options = select_file_criteria;
break;
}
// Populate select box and reset form.
$('#newcondition_cmd').empty();
@ -862,10 +880,18 @@ $('#ruleset')
var rule = $(this).closest('div.rule');
var type = rule.attr('type');
if (type == 'folder')
switch (type)
{
case 'folder':
options = select_folder_actions;
else
break;
case 'global':
options = select_global_actions;
break;
default:
options = select_file_actions;
break;
}
$('#edit_action_act').empty();
$.each(options, function(k, v) {