updated for new queue system

This commit is contained in:
hummypkg 2017-01-05 22:30:07 +00:00
parent a061396a39
commit cf0916ace6
5 changed files with 31 additions and 58 deletions

View File

@ -1,9 +1,9 @@
Package: sweeper
Priority: optional
Section: misc
Version: 2.1.4-2
Version: 2.1.5
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif(>=1.3.4-10)
Depends: webif(>=1.3.5)
Description: Sweeper is a package for managing recordings in a variety of ways using custom rules [See forum for details]
Tags: http://hummy.tv/forum/threads/5138/

View File

@ -10,6 +10,8 @@ proc ::sweeper::unknown {cmd args} {
return 0
}
alias ::sweeper::log ::auto::log
######################################################################
# Utility functions
@ -281,11 +283,9 @@ proc ::sweeper::expand {ts str {orig ""}} {
}
proc ::sweeper::resolvedir {dir} {
global root
if {$dir eq ""} { return $root }
if {$dir eq ""} { return $::auto::root }
if {[string index $dir 0] eq "/"} { return $dir }
return "$root/$dir"
return "$::auto::root/$dir"
}
# returns true if the arguments are actually the same file
@ -423,7 +423,7 @@ proc ::sweeper::folder_apply {dir callback args} {
}
proc ::sweeper::rmdir_if_empty {dir} {
if {$dir eq $::root} return
if {$dir eq $::auto::root} return
if {![system rmdir_if_empty $dir ".series"]} {
log "Failed to remove directory" 0
foreach l [system dirblockers $dir] {
@ -1183,40 +1183,27 @@ proc ::sweeper::apply {dir cf} {
# Callback function which is called from scan_run
proc ::sweeper::sweep {dir} {
if {$dir eq $::root} return
::sweeper::apply $dir "$dir/.sweeper"
if {$dir eq $::auto::root} return
apply $dir "$dir/.sweeper"
}
proc ::sweeper::scan {&files} {
log "::sweeper::scan files - ($files)" 2
set ::sweeper::renames {}
######################################################################
# Auto API callbacks
::sweeper::apply $::root $::sweeper::cf
scan_run $::root sweeper ::sweeper::sweep
log "::sweeper::scan renames - ($::sweeper::renames)" 2
if {[llength $::sweeper::renames]} {
foreach k [array names ::sweeper::renames] {
set pos [lsearch $files $k]
log "$k = pos $pos" 2
if {$pos == -1} continue
set files [lreplace $files $pos $pos \
$::sweeper::renames($k)]
}
log "::sweeper::scan files - ($files)" 2
}
proc ::sweeper::run {} {
apply $::auto::root $::sweeper::cf
::auto::flagscan $::auto::root sweeper ::sweeper::sweep
}
proc ::sweeper::scansingledir {dir} {
if {$dir eq $::root} {
::sweeper::apply $::root $::sweeper::cf
proc ::sweeper::rundir {dir} {
if {$dir eq $::auto::root} {
apply $::auto::root $::sweeper::cf
} elseif {[file exists "$dir/.sweeper"]} {
::sweeper::apply $dir "$dir/.sweeper"
apply $dir "$dir/.sweeper"
}
}
if {[file exists $::sweeper::cf]} {
register postdecryptscan ::sweeper::scan
register postdecryptsingledir ::sweeper::scansingledir
::auto::register sweeper 700
}

View File

@ -1,6 +1,7 @@
plugins.dmenu.sweeper = function(dir) {
window.location = '/plugin/sweeper/edit.jim?dir=' + dir;
window.location = '/plugin/sweeper/edit.jim?dir=' +
encodeURIComponent(dir);
};
plugins.dmenu.nosweep = function(dir, iconset, results, el) {

View File

@ -3,30 +3,16 @@ source /mod/webif/lib/setup
require lock system.class ts.class pretty_size browse.class \
safe_delete settings.class plugin queue.class
proc log {msg {level 1}} {
proc ::auto::log {msg {level 1}} {
puts "[\
clock format [clock seconds] -format "%d/%m/%Y %H:%M"\
] - $msg"
}
proc elapsed {start} {
return $(([clock milliseconds] - $start) / 1000.0)
}
proc ::auto::register {args} {}
proc startclock {} {
set ::startclock_s [clock milliseconds]
}
proc endclock {size} {
set el [elapsed $::startclock_s]
set rate $($size / $el)
return "[pretty_size $size] in $el seconds - [pretty_size $rate]/s"
}
proc register {args} {}
proc scan_run {dir flag callback {seen {}}} {
global dustbin
proc ::auto::flagscan {dir flag callback {seen {}}} {
variable dustbin
if {[string match {\[*} [string trimleft [file tail $dir]]]} return
@ -42,7 +28,7 @@ proc scan_run {dir flag callback {seen {}}} {
foreach entry [readdir -nocomplain $dir] {
if {[file isdirectory "$dir/$entry"]} {
scan_run "$dir/$entry" $flag $callback $seen
flagscan "$dir/$entry" $flag $callback $seen
file stat "$dir/$entry" st
set key "$st(dev):$st(ino)"
@ -51,7 +37,7 @@ proc scan_run {dir flag callback {seen {}}} {
}
}
set root [system mediaroot]
set ::auto::root [system mediaroot]
source /mod/webif/plugin/sweeper/auto.hook

View File

@ -3,11 +3,10 @@
source /mod/webif/plugin/sweeper/harness.jim
if {![llength $argv]} {
set files {}
::sweeper::scan files
::sweeper::run
} else {
scan_run [lindex $argv 0] sweeper ::sweeper::sweep
foreach dir $argv {
::sweeper::rundir $dir
}
}
#::sweeper::apply $::root $::sweeper::cf