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 Package: sweeper
Priority: optional Priority: optional
Section: misc Section: misc
Version: 2.1.4-2 Version: 2.1.5
Architecture: mipsel Architecture: mipsel
Maintainer: af123@hummypkg.org.uk 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] 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/ Tags: http://hummy.tv/forum/threads/5138/

View File

@ -10,6 +10,8 @@ proc ::sweeper::unknown {cmd args} {
return 0 return 0
} }
alias ::sweeper::log ::auto::log
###################################################################### ######################################################################
# Utility functions # Utility functions
@ -281,11 +283,9 @@ proc ::sweeper::expand {ts str {orig ""}} {
} }
proc ::sweeper::resolvedir {dir} { proc ::sweeper::resolvedir {dir} {
global root if {$dir eq ""} { return $::auto::root }
if {$dir eq ""} { return $root }
if {[string index $dir 0] eq "/"} { return $dir } 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 # 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} { proc ::sweeper::rmdir_if_empty {dir} {
if {$dir eq $::root} return if {$dir eq $::auto::root} return
if {![system rmdir_if_empty $dir ".series"]} { if {![system rmdir_if_empty $dir ".series"]} {
log "Failed to remove directory" 0 log "Failed to remove directory" 0
foreach l [system dirblockers $dir] { foreach l [system dirblockers $dir] {
@ -1183,40 +1183,27 @@ proc ::sweeper::apply {dir cf} {
# Callback function which is called from scan_run # Callback function which is called from scan_run
proc ::sweeper::sweep {dir} { proc ::sweeper::sweep {dir} {
if {$dir eq $::root} return if {$dir eq $::auto::root} return
::sweeper::apply $dir "$dir/.sweeper" apply $dir "$dir/.sweeper"
} }
proc ::sweeper::scan {&files} { ######################################################################
log "::sweeper::scan files - ($files)" 2 # Auto API callbacks
set ::sweeper::renames {}
::sweeper::apply $::root $::sweeper::cf proc ::sweeper::run {} {
scan_run $::root sweeper ::sweeper::sweep apply $::auto::root $::sweeper::cf
::auto::flagscan $::auto::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::scansingledir {dir} { proc ::sweeper::rundir {dir} {
if {$dir eq $::root} { if {$dir eq $::auto::root} {
::sweeper::apply $::root $::sweeper::cf apply $::auto::root $::sweeper::cf
} elseif {[file exists "$dir/.sweeper"]} { } elseif {[file exists "$dir/.sweeper"]} {
::sweeper::apply $dir "$dir/.sweeper" apply $dir "$dir/.sweeper"
} }
} }
if {[file exists $::sweeper::cf]} { if {[file exists $::sweeper::cf]} {
register postdecryptscan ::sweeper::scan ::auto::register sweeper 700
register postdecryptsingledir ::sweeper::scansingledir
} }

View File

@ -1,6 +1,7 @@
plugins.dmenu.sweeper = function(dir) { 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) { 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 \ require lock system.class ts.class pretty_size browse.class \
safe_delete settings.class plugin queue.class safe_delete settings.class plugin queue.class
proc log {msg {level 1}} { proc ::auto::log {msg {level 1}} {
puts "[\ puts "[\
clock format [clock seconds] -format "%d/%m/%Y %H:%M"\ clock format [clock seconds] -format "%d/%m/%Y %H:%M"\
] - $msg" ] - $msg"
} }
proc elapsed {start} { proc ::auto::register {args} {}
return $(([clock milliseconds] - $start) / 1000.0)
}
proc startclock {} { proc ::auto::flagscan {dir flag callback {seen {}}} {
set ::startclock_s [clock milliseconds] variable dustbin
}
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
if {[string match {\[*} [string trimleft [file tail $dir]]]} return 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] { foreach entry [readdir -nocomplain $dir] {
if {[file isdirectory "$dir/$entry"]} { if {[file isdirectory "$dir/$entry"]} {
scan_run "$dir/$entry" $flag $callback $seen flagscan "$dir/$entry" $flag $callback $seen
file stat "$dir/$entry" st file stat "$dir/$entry" st
set key "$st(dev):$st(ino)" 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 source /mod/webif/plugin/sweeper/auto.hook

View File

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