Index: openacs-4/packages/attachments/www/file-add-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/file-add-2.tcl,v
diff -u -N -r1.13 -r1.14
--- openacs-4/packages/attachments/www/file-add-2.tcl 6 Dec 2018 14:26:00 -0000 1.13
+++ openacs-4/packages/attachments/www/file-add-2.tcl 6 Dec 2018 15:48:10 -0000 1.14
@@ -27,7 +27,7 @@
from fs_root_folders
where folder_id=:root_folder
}]
- set max_bytes [parameter::get -package_id $fs_package_id -parameter "MaximumFileSize"]
+ set max_bytes [fs::max_upload_size -package_id $fs_package_id]
if { $n_bytes > $max_bytes } {
# Max number of bytes is used in the error message
set max_number_of_bytes [util_commify_number $max_bytes]
Index: openacs-4/packages/file-storage/file-storage.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/file-storage.info,v
diff -u -N -r1.59 -r1.60
--- openacs-4/packages/file-storage/file-storage.info 7 Aug 2017 23:48:11 -0000 1.59
+++ openacs-4/packages/file-storage/file-storage.info 6 Dec 2018 15:48:10 -0000 1.60
@@ -7,7 +7,7 @@
f
f
-
+
OpenACS
Collaborative document storage
2017-08-06
@@ -17,7 +17,7 @@
2
#file-storage.file-storage#
-
+
@@ -45,7 +45,7 @@
-
+
Index: openacs-4/packages/file-storage/tcl/file-storage-install-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-install-procs.tcl,v
diff -u -N -r1.16 -r1.17
--- openacs-4/packages/file-storage/tcl/file-storage-install-procs.tcl 10 Jul 2018 09:39:30 -0000 1.16
+++ openacs-4/packages/file-storage/tcl/file-storage-install-procs.tcl 6 Dec 2018 15:48:10 -0000 1.17
@@ -149,8 +149,34 @@
5.1.0a11 5.1.0a12 {
fs::rss::create_rss_gen_subscr_impl
}
+ 5.10.0d1 5.10.0d2 {
+ # Get max upload size from server conf
+ set driver [expr {[ns_conn isconnected] ?
+ [ns_conn driver] :
+ [lindex [ns_driver names] 0]}]
+ set section [ns_driversection -driver $driver]
+ set max_bytes_conf [ns_config $section maxinput]
+ # Get all file-storage instances
+ foreach package_id [db_list get_fs_instances {
+ select package_id from apm_packages where package_key = 'file-storage'
+ }] {
+ # Get max upload size from package parameter
+ set max_bytes_param [parameter::get -package_id $package_id -parameter "MaximumFileSize"]
+ if {![string is double -strict $max_bytes_param]} {
+ set max_bytes_param Inf
+ }
+ # If value from parameter is larger than the one
+ # from server conf, just reset the parameter and
+ # let server value overtake. (You won't be able to
+ # upload such big files anyway)
+ if {$max_bytes_param >= $max_bytes_conf} {
+ parameter::set_value \
+ -package_id $package_id \
+ -parameter "MaximumFileSize" -value ""
+ }
+ }
+ }
}
-
}
ad_proc -private ::install::xml::action::file-storage-folder { node } {
Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v
diff -u -N -r1.89 -r1.90
--- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 21 Sep 2018 14:11:55 -0000 1.89
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 6 Dec 2018 15:48:10 -0000 1.90
@@ -1660,6 +1660,32 @@
return [join $categories $joinwith]
}
+ad_proc -private fs::max_upload_size {
+ {-package_id ""}
+} {
+ @param package_id id of the file-storage package instance. Will
+ default to the connection package_id if not specified.
+
+ Returns the maximum upload size for this file-storage instance. If
+ the value from the parameter is empty, invalid, or bigger than
+ the server-wide upload limit, the latter will take over.
+
+ @return numeric value in bytes
+} {
+ set max_bytes_param [parameter::get -package_id $package_id -parameter "MaximumFileSize"]
+ if {![string is double -strict $max_bytes_param]} {
+ set max_bytes_param Inf
+ }
+
+ set driver [expr {[ns_conn isconnected] ?
+ [ns_conn driver] :
+ [lindex [ns_driver names] 0]}]
+ set section [ns_driversection -driver $driver]
+ set max_bytes_conf [ns_config $section maxinput]
+
+ return [expr {min($max_bytes_param,$max_bytes_conf)}]
+}
+
# Local variables:
# mode: tcl
# tcl-indent-level: 4
Index: openacs-4/packages/file-storage/www/file-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-add.tcl,v
diff -u -N -r1.23 -r1.24
--- openacs-4/packages/file-storage/www/file-add.tcl 17 Sep 2018 14:23:17 -0000 1.23
+++ openacs-4/packages/file-storage/www/file-add.tcl 6 Dec 2018 15:48:10 -0000 1.24
@@ -36,7 +36,7 @@
}
max_size -requires {upload_file} {
set n_bytes [file size ${upload_file.tmpfile}]
- set max_bytes [parameter::get -parameter "MaximumFileSize"]
+ set max_bytes [fs::max_upload_size]
if { $n_bytes > $max_bytes } {
ad_complain "Your file is larger than the maximum file size allowed on this system ([util_commify_number $max_bytes] bytes)"
}
Index: openacs-4/packages/file-storage/www/folder-zip-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-zip-add.tcl,v
diff -u -N -r1.10 -r1.11
--- openacs-4/packages/file-storage/www/folder-zip-add.tcl 13 Sep 2018 09:53:03 -0000 1.10
+++ openacs-4/packages/file-storage/www/folder-zip-add.tcl 6 Dec 2018 15:48:10 -0000 1.11
@@ -32,7 +32,7 @@
}
max_size -requires {upload_file} {
set n_bytes [file size ${upload_file.tmpfile}]
- set max_bytes [parameter::get -parameter "MaximumFileSize"]
+ set max_bytes [fs::max_upload_size]
if { $n_bytes > $max_bytes } {
ad_complain "Your file is larger than the maximum file size allowed on this system ([util_commify_number $max_bytes] bytes)"
}
Index: openacs-4/packages/file-storage/www/admin/upload-size-limit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/admin/upload-size-limit.tcl,v
diff -u -N -r1.9 -r1.10
--- openacs-4/packages/file-storage/www/admin/upload-size-limit.tcl 19 Jan 2018 14:18:32 -0000 1.9
+++ openacs-4/packages/file-storage/www/admin/upload-size-limit.tcl 6 Dec 2018 15:48:10 -0000 1.10
@@ -19,7 +19,7 @@
set title "#file-storage.Configure_File_Upload_Limit#"
set context [list $title]
-set upload_limit [parameter::get -parameter "MaximumFileSize"]
+set upload_limit [fs::max_upload_size]
ad_form -name upload_limit_size -export folder_id -form {
{new_size:integer(text) {label "#file-storage.Upload_Limit# $max_size"} {value $upload_limit} {html { maxlength 10}}}