From cf0916ace6c772ae0644f55c6dffca65b117047c Mon Sep 17 00:00:00 2001 From: hummypkg Date: Thu, 5 Jan 2017 22:30:07 +0000 Subject: [PATCH] updated for new queue system --- CONTROL/control | 4 +-- webif/plugin/sweeper/auto.hook | 47 ++++++++++++-------------------- webif/plugin/sweeper/browse.js | 3 +- webif/plugin/sweeper/harness.jim | 26 ++++-------------- webif/plugin/sweeper/test | 9 +++--- 5 files changed, 31 insertions(+), 58 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index b2b1b52..283086a 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -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/ diff --git a/webif/plugin/sweeper/auto.hook b/webif/plugin/sweeper/auto.hook index 2667e84..e8359ec 100644 --- a/webif/plugin/sweeper/auto.hook +++ b/webif/plugin/sweeper/auto.hook @@ -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 } diff --git a/webif/plugin/sweeper/browse.js b/webif/plugin/sweeper/browse.js index ec73802..3a9b6f6 100644 --- a/webif/plugin/sweeper/browse.js +++ b/webif/plugin/sweeper/browse.js @@ -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) { diff --git a/webif/plugin/sweeper/harness.jim b/webif/plugin/sweeper/harness.jim index 7a2d05b..88cd529 100755 --- a/webif/plugin/sweeper/harness.jim +++ b/webif/plugin/sweeper/harness.jim @@ -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 diff --git a/webif/plugin/sweeper/test b/webif/plugin/sweeper/test index c2a7659..058a163 100755 --- a/webif/plugin/sweeper/test +++ b/webif/plugin/sweeper/test @@ -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