diff --git a/CONTROL/control b/CONTROL/control
index 7aebf04..e0433be 100644
--- a/CONTROL/control
+++ b/CONTROL/control
@@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
-Version: 0.8.11
+Version: 0.8.11-1
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.5),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.4),ssmtp,anacron
diff --git a/var/mongoose/cgi-bin/backup/restore.jim b/var/mongoose/cgi-bin/backup/restore.jim
index 67c845c..5b01a43 100755
--- a/var/mongoose/cgi-bin/backup/restore.jim
+++ b/var/mongoose/cgi-bin/backup/restore.jim
@@ -106,7 +106,7 @@ foreach line $data {
puts " $chan"
- if {!$hsvc} {
+ if {$hsvc eq ""} {
puts " Cannot map channel name to service."
continue
}
diff --git a/var/mongoose/cgi-bin/browse/clipboard.jim b/var/mongoose/cgi-bin/browse/clipboard.jim
index 50b735b..70d772c 100755
--- a/var/mongoose/cgi-bin/browse/clipboard.jim
+++ b/var/mongoose/cgi-bin/browse/clipboard.jim
@@ -2,9 +2,12 @@
package require cgi
source /mod/var/mongoose/lib/setup
-require clipboard.class ts.class chunked
+require clipboard.class ts.class
-start_chunked "text/html; no-cache\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nPragma: nocache"
+puts "Content-Type: text/html; no-cache"
+puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT"
+puts "Pragma: nocache"
+puts ""
cgi_input 1
#cgi_dump
@@ -16,10 +19,10 @@ set action [cgi_get act list]
switch $action {
list {
if {![$cb size]} {
- chunk "Clipboard is empty"
+ puts "Clipboard is empty"
break
}
- chunk "
"
+ puts "
"
- chunk "
"
+ puts "
"
+ puts ""
}
add {
if {[set path [cgi_get path]] eq "0"} {
- chunk "No path."
+ puts "No path."
exit
}
set dir [cgi_unquote_input [cgi_get dir]]
@@ -56,12 +59,12 @@ switch $action {
foreach p $path {
set p [cgi_unquote_input $p]
if {$dir ne "0" && ![string match "$dir/*" $p]} {
- chunk "$p not in directory
"
+ puts "$p not in directory
"
continue
}
if {![$cb present $p]} {
$cb add $mode $p
- chunk "Added $p for $mode
"
+ puts "Added $p for $mode
"
}
}
$cb save
@@ -81,16 +84,15 @@ switch $action {
set file [file tail $path]
set mode [$item get action]
- chunk "Pasting $file"
- chunk_pad
+ puts "Pasting $file"
if {[file isdirectory $path]} {
# Directory
if {$mode eq "cut"} {
- file rename $path "$dir/$file"
+ catch {file rename $path "$dir/$file"}
} else {
- chunk [exec /mod/bin/busybox/cp -r \
- $path $dir]
+ catch {puts [exec /mod/bin/busybox/cp -r \
+ $path $dir]}
}
} else {
set root [file rootname $path]
@@ -100,9 +102,9 @@ switch $action {
regsub -all {([\\["$])} $root {\\\1} root
foreach f [glob -nocomplain "${root}.*"] {
if {$mode eq "cut"} {
- file rename $f "$dir/[file tail $f]"
+ catch {file rename $f "$dir/[file tail $f]"}
} else {
- file copy $f "$dir/[file tail $f]"
+ catch {file copy $f "$dir/[file tail $f]"}
}
}
}
@@ -112,5 +114,3 @@ switch $action {
}
}
-end_chunked
-
diff --git a/var/mongoose/cgi-bin/browse/delete.jim b/var/mongoose/cgi-bin/browse/delete.jim
index c5538e4..4387b84 100755
--- a/var/mongoose/cgi-bin/browse/delete.jim
+++ b/var/mongoose/cgi-bin/browse/delete.jim
@@ -1,7 +1,8 @@
#!/mod/bin/jimsh
package require cgi
-source /mod/var/mongoose/lib/ts.class
+source /mod/var/mongoose/lib/setup
+require ts.class system.class
puts "Content-Type: text/html"
puts ""
@@ -12,21 +13,50 @@ cgi_input
set file [dict get $_cgi file]
set type [dict get $_cgi type]
+if {[system pkginst undelete]} {
+ set dustbin [system dustbin]
+} else {
+ set dustbin ""
+}
+
+proc bindir {file} {
+ global dustbin
+ set dir [file dirname $file]
+ regsub "^[system mediaroot]" $dir $dustbin dir
+ system mkdir_p $dir
+ return $dir
+}
+
if {$type eq "ts"} {
set ts [ts fetch $file]
- if {[$ts delete]} {
- puts "Successfully deleted $file."
+ if {$dustbin ne ""} {
+ $ts move [bindir $file]
} else {
- puts "Problem deleting $file, [$ts get error]"
+ if {[$ts delete]} {
+ puts "Successfully deleted $file."
+ } else {
+ puts "Problem deleting $file, [$ts get error]"
+ }
}
exit
} elseif {$type eq "dir"} {
puts -nonewline "Directory..."
- puts [exec /mod/bin/busybox/rm -rf $file]
+ if {$dustbin ne ""} {
+ set ndir "[bindir $file]/[file tail $file]"
+ while {[file isdirectory $ndir]} { append ndir "_" }
+ file rename $file $ndir
+ } else {
+ puts [exec /mod/bin/busybox/rm -rf $file]
+ }
puts -nonewline "Done..."
} else {
- file delete $file
- file delete "[file rootname $file].hmi"
+ if {$dustbin ne ""} {
+ file rename $file "[bindir $file]/[file tail $file]"
+ } else {
+ file delete $file
+ }
+ catch {file delete "[file rootname $file].hmi"}
+
puts "Successfully deleted $file."
}
diff --git a/var/mongoose/cgi-bin/browse/mdelete.jim b/var/mongoose/cgi-bin/browse/mdelete.jim
index f5cae31..845a0ae 100755
--- a/var/mongoose/cgi-bin/browse/mdelete.jim
+++ b/var/mongoose/cgi-bin/browse/mdelete.jim
@@ -2,7 +2,7 @@
package require cgi
source /mod/var/mongoose/lib/setup
-require ts.class pretty_size
+require ts.class pretty_size system.class
puts "Content-Type: text/html\r\n\r\n"
@@ -13,6 +13,20 @@ set dir [cgi_unquote_input [cgi_get dir]]
#puts "DIR: ($dir)"
+if {[system pkginst undelete]} {
+ set dustbin [system dustbin]
+} else {
+ set dustbin ""
+}
+
+proc bindir {file} {
+ global dustbin
+ set dir [file dirname $file]
+ regsub "^[system mediaroot]" $dir $dustbin dir
+ system mkdir_p $dir
+ return $dir
+}
+
puts "Deleting...
"
puts ""
foreach file [cgi_get files] {
@@ -25,22 +39,33 @@ foreach file [cgi_get files] {
if {[file isdirectory $file]} {
puts -nonewline "Directory..."
- puts [exec /mod/bin/busybox/rm -rf $file]
+ if {$dustbin ne ""} {
+ set ndir "[bindir $file]/[file tail $file]"
+ while {[file isdirectory $ndir]} { append ndir "_" }
+ file rename $file $ndir
+ } else {
+ puts [exec /mod/bin/busybox/rm -rf $file]
+ }
puts -nonewline "Done..."
} elseif {[string match {*.ts} $file]} {
set ts [ts fetch $file]
- if {[catch {$ts delete} msg]} {
- puts -nonewline "Error loading TS file..."
+ if {$dustbin ne ""} {
+ $ts move [bindir $file]
} else {
- puts -nonewline "Done..."
+ if {[$ts delete]} {
+ puts "Successfully deleted $file."
+ } else {
+ puts "Problem deleting $file, [$ts get error]"
+ }
}
} else {
- if {[catch {file delete $file} msg]} {
- puts -nonewline "Error: $msg"
+ if {$dustbin ne ""} {
+ file rename $file "[bindir $file]/[file tail $file]"
} else {
- catch {file delete "[file rootname $file].hmi"}
- puts -nonewline "Done..."
+ file delete $file
}
+ catch {file delete "[file rootname $file].hmi"}
+ puts -nonewline "Done..."
}
puts ""
}
diff --git a/var/mongoose/lib/system.class b/var/mongoose/lib/system.class
index d4f3988..daa6c86 100644
--- a/var/mongoose/lib/system.class
+++ b/var/mongoose/lib/system.class
@@ -50,6 +50,14 @@ proc {system mediaroot} {} {
return ""
}
+proc {system dustbin} {} {
+ switch [system model] {
+ HDR { return "/media/My Video/_dustbin" }
+ HD { return "/media/drive1/Video/_dustbin" }
+ }
+ return ""
+}
+
proc {system diskspace} {} {
switch [system model] {
HDR { set part /mnt/hd2 }
@@ -116,3 +124,7 @@ proc {system padding} {} {
return [list $start $stop]
}
+proc {system mkdir_p} {dir} {
+ exec /mod/bin/busybox/mkdir -p $dir
+}
+
diff --git a/var/mongoose/lib/ts.class b/var/mongoose/lib/ts.class
index 240a46d..5c972ac 100644
--- a/var/mongoose/lib/ts.class
+++ b/var/mongoose/lib/ts.class
@@ -118,14 +118,36 @@ proc {ts fetch} {file {checked 0}} {
}
ts method delete {} {
- # Extract file basename
- foreach f [glob -nocomplain "[file rootname $file].*"] {
+ set root [file rootname $file]
+ # Protect special characters in root.
+ # In particular [] characters which are used a lot
+ # for torrent names.
+ regsub -all {([\\["$])} $root {\\\1} root
+ foreach f [glob -nocomplain "${root}.*"] {
puts "Removed $f
"
file delete $f
}
return 1
}
+ts method move {dst} {
+ set root [file rootname $file]
+ regsub -all {([\\["$])} $root {\\\1} root
+ foreach f [glob -nocomplain "${root}.*"] {
+ file rename $f "$dst/[file tail $f]"
+ }
+ return 1
+}
+
+ts method copy {dst} {
+ set root [file rootname $file]
+ regsub -all {([\\["$])} $root {\\\1} root
+ foreach f [glob -nocomplain "${root}.*"] {
+ file copy $f "$dst/[file tail $f]"
+ }
+ return 1
+}
+
ts method settitle {newtitle} {
if {[string length newtitle] > 48} { return }