From d5b27acd462a4b971e0b542f1e67b7229c2ae0ee Mon Sep 17 00:00:00 2001 From: hummypkg Date: Sat, 20 Aug 2011 20:45:23 +0000 Subject: [PATCH] fix minor file browser bugs git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@291 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- var/mongoose/cgi-bin/browse/download.jim | 5 +++-- var/mongoose/cgi-bin/browse/sizes.jim | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index 8fd050f..221585f 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.6.4 +Version: 0.6.4-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.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.2),hmt(>=1.0.6),ssmtp diff --git a/var/mongoose/cgi-bin/browse/download.jim b/var/mongoose/cgi-bin/browse/download.jim index 177f004..32d4eaa 100755 --- a/var/mongoose/cgi-bin/browse/download.jim +++ b/var/mongoose/cgi-bin/browse/download.jim @@ -5,6 +5,8 @@ package require sqlite3 source /mod/var/mongoose/lib/setup require ts.class +#puts "Content-Type: text/plain\r\n\r\n" + cgi_input #cgi_dump @@ -21,8 +23,7 @@ if {[file exists $dmsfile]} { set muri [$db query " select tblresource.mimetype, contenturi from tblresource join tblmedia using (mediaid) - where localurl = '$rfile' - "] + where localurl = '%s'" $rfile] if {$muri != ""} { set rec [lindex $muri 0] set xuri [lindex $rec 3] diff --git a/var/mongoose/cgi-bin/browse/sizes.jim b/var/mongoose/cgi-bin/browse/sizes.jim index 6dca32c..a1ef136 100755 --- a/var/mongoose/cgi-bin/browse/sizes.jim +++ b/var/mongoose/cgi-bin/browse/sizes.jim @@ -2,6 +2,7 @@ package require cgi +#puts "Content-Type: text/plain" puts "Content-Type: application/json" puts "" @@ -18,9 +19,24 @@ puts "{" foreach line [split [exec /mod/bin/busybox/du -h "$dir/"] "\n"] { set fields [split $line "\t"] set size [lindex $fields 0] - set node [lindex [split [lindex $fields 1] /] end] + set node [file tail [lindex $fields 1]] +# set node [lindex [split [lindex $fields 1] /] end] puts "\"$node\" : \"$size\"," } + +# Handle symbolic links. +foreach file [glob -nocomplain "$dir/*"] { + if {[catch {set lk [file readlink $file]}]} continue + foreach line [split [exec /mod/bin/busybox/du -h "$lk"] "\n"] { + set fields [split $line "\t"] + if {[lindex $fields 1] eq $lk} { + set node [file tail $file] + set size [lindex $fields 0] + puts "\"$node\" : \"@$size\"," + } + } +} + puts "\"dummy\" : \"\"" puts "}"