pa_expand_archive (public)
pa_expand_archive upload_file tmpfile [ dest_dir_base ]
Defined in packages/photo-album/tcl/photo-album-procs.tcl
Given an uploaded file in file tmpfile with original name upload_file extract the archive and put in a tmp directory which is the return value of the function
- Parameters:
- upload_file (required)
- tmpfile (required)
- dest_dir_base (optional, defaults to
"extract"
)- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set tmp_dir [file join [file dirname $tmpfile] [ns_mktemp "$dest_dir_base-XXXXXX"]] if {[catch { file mkdir $tmp_dir } errMsg ]} { ns_log Warning "pa_expand_archive: Error creating directory $tmp_dir: $errMsg" return -code error "pa_expand_archive: Error creating directory $tmp_dir: $errMsg" } set upload_file [string trim [string tolower $upload_file]] if {[regexp {(.tar.gz|.tgz)$} $upload_file]} { set type tgz } elseif {[regexp {.tar.z$} $upload_file]} { set type tgZ } elseif {[regexp {.tar$} $upload_file]} { set type tar } elseif {[regexp {(.tar.bz2|.tbz2)$} $upload_file]} { set type tbz2 } elseif {[regexp {.zip$} $upload_file]} { set type zip } else { set type "Unknown type" } # DRB: on macOS the "verify" option to tar appears to return the file # list on stderr rather than stdout, causing the catch to trigger. Non-GNU # versions of tar don't understand fancy options (those starting with --) switch $type { tar { set errp [ catch { exec tar -xf $tmpfile -C $tmp_dir } errMsg] } tgZ { set errp [ catch { exec tar -xZf $tmpfile -C $tmp_dir } errMsg] } tgz { set errp [ catch { exec tar -xzf $tmpfile -C $tmp_dir } errMsg] } tbz2 { set errp [ catch { exec tar -xjf $tmpfile -C $tmp_dir } errMsg] } zip { set errp [ catch { exec unzip -d $tmp_dir $tmpfile } errMsg] } default { set errp 1 set errMsg "don't know how to extract $upload_file" } } if {$errp} { file delete -force $tmp_dir ns_log Warning "pa_expand_archive: extract type $type failed $errMsg" return -code error "pa_expand_archive: extract type $type failed $errMsg" } return $tmp_dirGeneric XQL file: packages/photo-album/tcl/photo-album-procs.xql
PostgreSQL XQL file: packages/photo-album/tcl/photo-album-procs-postgresql.xql
Oracle XQL file: packages/photo-album/tcl/photo-album-procs-oracle.xql