Index: openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl 17 Oct 2001 19:44:08 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl 5 Jul 2002 16:32:19 -0000 1.2 @@ -7,16 +7,60 @@ @cvs-id $Id$ } +ad_proc -private mp3_opendir { + dir + {file_type f} + {return_style short} +} { + Use: opendir dir ?file_type? ?return_style? + return a list of files or directories. + Arguments: dir Directory to return (required) + file_type "d" for directories, + "f" for files (default), + "a" for all + return_style "short" for filenames only, + "long" for full paths + Returns list of files/directories on success, "" on failure +} { + set temp_dirs "" + set temp_files "" + set files [glob -nocomplain "$dir/*"] + foreach file $files { + if {[file isfile $file] == 1} {lappend temp_files $file} + if {[file isdirectory $file] == 1} {lappend temp_dirs $file} + } + switch $file_type { + a { set out [concat $temp_files $temp_dirs]} + f { set out $temp_files } + d { set out $temp_dirs } + default {error "File type argument $file_type not known. Must be d f or a"} + } + switch $return_style { + long { return $out } + short { + set short_out "" + foreach file $out { + lappend short_out [file tail $file] + } + return $short_out + } + default {error "Return type argument $return_style not known. Must be short or long"} + } +} + + ad_proc -public get_list_of_mp3s { } { This proc uses the package_id to check an appropriate directory. It uses ad_parameter to check the MP3FileLocation variable. } { set package_id [ad_conn package_id] - set file_list [exec /usr/bin/find [ad_parameter -package_id $package_id MP3StagingLocation] ] + set staging_path [ad_parameter -package_id $package_id MP3StagingLocation] + # set file_list [exec /usr/bin/find [ad_parameter -package_id $package_id MP3StagingLocation] ] + set file_list [mp3_opendir $staging_path] return $file_list } Index: openacs-4/contrib/obsolete-packages/mp3-jukebox/www/admin/scanner.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/mp3-jukebox/www/admin/scanner.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/mp3-jukebox/www/admin/scanner.tcl 17 Oct 2001 19:44:08 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/mp3-jukebox/www/admin/scanner.tcl 5 Jul 2002 16:32:19 -0000 1.2 @@ -3,15 +3,20 @@ } { } +# modified 12/18/2001 to fix bugs when attempting to scan files with spaces +# ivan@anilak.com + set user_id [ad_verify_and_get_user_id] set package_id [ad_conn package_id] set creation_ip [ad_conn "peeraddr"] set creation_user [ad_conn "user_id"] set file_list [get_list_of_mp3s] +set page_html "" +if {[llength $file_list] == 0} {append page_html "No files found in Staging Location"} - foreach file_name $file_list { + set staging_filename "[ad_parameter MP3StagingLocation]/$file_name" if {![regexp {(([^/]*)\.[mM][Pp]3)$} $file_name match client_filename mp3_name] } { append page_html "Broke on $file_name
\n" continue @@ -24,22 +29,22 @@ if { $deleted_p == "f" } { append page_html "$file_name is already in the db. Continuing.
\n" + file delete -force "$staging_filename" continue } else { set update_entry_p 1 } } else { set update_entry_p 0 } -# if {[db_string mp3_exists "select count(*) from mp3_mp3s where file_path = :client_filename"] != 0} { -# append page_html "$file_name is already in the db. Continuing.
" -# continue -# } set target_filename "[ad_parameter MP3FileLocation]/$client_filename" - file copy -force $file_name $target_filename + file copy -force "$staging_filename" "$target_filename" + ns_log notice "DELETE:$staging_filename" + file delete -force "$staging_filename" + -set mp3_info_list [exec "[acs_root_dir]/packages/mp3-jukebox/bin/mp3_file_scan" $target_filename] +set mp3_info_list [exec "[acs_root_dir]/packages/mp3-jukebox/bin/mp3_file_scan" "$target_filename"] # Workaround due to plpgsql (as of PG 7.1.3) being unable to handle # default values in functions): # The number of items in "mp3_info_list" may vary so we initialize Index: openacs-4/contrib/obsolete-packages/mp3-jukebox/www/m3u/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/mp3-jukebox/www/m3u/index.vuh,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/mp3-jukebox/www/m3u/index.vuh 17 Oct 2001 19:44:08 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/mp3-jukebox/www/m3u/index.vuh 5 Jul 2002 16:32:19 -0000 1.2 @@ -16,7 +16,7 @@ order by m.sort_key " { - append page_text "http://jk30.ybos.net/mp3/mp3s/$mp3_id/$title.mp3\n" + append page_text "[ad_conn location][ad_conn package_url]mp3s/$mp3_id/$title.mp3\n" } if_no_rows { set page_text "" }