webif/var/mongoose/html/dedup/process.jim
hummypkg 22320536ee browse relocation, system class improvements, safe_delete improvements, auto expire, utf-8, ...
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1420 2a923420-c742-0410-a762-8d5b09965624
2013-02-25 22:31:54 +00:00

39 lines
816 B
Plaintext
Executable File

#!/mod/bin/jimsh
require system.class
proc dedupprocess {file} {{seen {}}} {
set ts [ts fetch $file 1]
if {[$ts flag "Deduped"]} {
lappend seen [file rootname [file tail $file]]
return [list nothing $ts "" ""]
}
set dir [file dirname $file]
set base [file tail [file rootname $file]]
set syn [dedupnormalise [$ts get synopsis] [$ts get title]]
# Escape special characters to create the filename.
regsub -all -- {[\/ &]} $syn "_" fn
regsub -all -- {[?]} $fn "" fn
set stat ok
if {[$ts inuse]} {
set stat inuse
} elseif {$fn in $seen} {
set stat dup
} elseif {[string length $syn] > 40} {
set stat error
} elseif {$base eq $fn} {
set stat nothing
$ts set_deduped
} elseif {[file exists "$dir/$fn.ts"]} {
set stat preserve
}
lappend seen $fn
return [list $stat $ts $syn $fn]
}