add renamed file handling

This commit is contained in:
hummypkg 2014-07-07 22:06:04 +00:00
parent 2ec708a887
commit 08a1f09221
3 changed files with 30 additions and 4 deletions

View File

@ -4,6 +4,6 @@ Section: misc
Version: 2.0.7
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif(>=1.0.15-5)
Depends: webif(>=1.0.15-7)
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

@ -167,6 +167,9 @@ proc ::sweeper::moveset {ts dst {op rename}} {
return
}
}
if {$op eq "rename"} {
set ::sweeper::renames($file) "$dst/[file tail $file]"
}
return
}
@ -192,6 +195,9 @@ proc ::sweeper::moveset {ts dst {op rename}} {
return
}
}
if {$op eq "rename"} {
set ::sweeper::renames($file) "$dst/[file tail $file]"
}
}
# Search for a folder with name 'target' under 'root', skipping 'orig'
@ -428,7 +434,7 @@ proc ::sweeper::action_move {ts cmd arg folder} {
::sweeper::folder_apply [$ts dir] \
::sweeper::action_move $ocmd $arg 0
if {$cmd eq "move"} {
::sweeper::rmdir_if_empty $dir
::sweeper::rmdir_if_empty [$ts dir]
}
return 1
}
@ -451,6 +457,9 @@ proc ::sweeper::action_move {ts cmd arg folder} {
if {!$::sweeper::dryrun} {
::sweeper::moveset $ts $dir $cmd
::sweeper::qrecalc $dir [$ts dir]
if {$cmd eq "move"} {
::sweeper::rmdir_if_empty [$ts dir]
}
}
return 1
}
@ -525,6 +534,7 @@ proc ::sweeper::action_renamefile {ts cmd arg folder} {
ts renamegroup $file $arg
if {[file exists "$dir/$arg.ts"]} {
$ts setfile "$dir/$arg.ts"
set ::sweeper::renames($file) "$dir/$arg.ts"
} else {
log "... ERROR renamefile somehow failed" 0
}
@ -827,9 +837,24 @@ proc ::sweeper::sweep {dir} {
::sweeper::apply $dir "$dir/.sweeper"
}
proc ::sweeper::scan {args} {
proc ::sweeper::scan {&files} {
log "::sweeper::scan files - ($files)" 2
set ::sweeper::renames {}
::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
}
}
if {[file exists $::sweeper::cf]} {

View File

@ -3,7 +3,8 @@
source /mod/webif/plugin/sweeper/harness.jim
if {![llength $argv]} {
::sweeper::scan 0
set files {}
::sweeper::scan files
} else {
scan_run [lindex $argv 0] sweeper ::sweeper::sweep
}