diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-02-24 08:31:56 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2024-02-24 08:31:56 +0000 |
| commit | 3195fa24a869c19a4e717b15650cba66d4d43d3b (patch) | |
| tree | 7bb3cec7e9850b4353d26ffff63d3611022da3ce | |
| parent | 03ae2e4b24b0c9f2b93bf4b472c4aa5e2daed946 (diff) | |
| download | apaste-3195fa24a869c19a4e717b15650cba66d4d43d3b.tar.gz | |
Prepare for 0.0.2.0; add apasted -S maxtotalsize
Signed-off-by: Laurent Bercot <ska@appnovation.com>
| -rw-r--r-- | NEWS | 6 | ||||
| -rw-r--r-- | doc/apasted.html | 8 | ||||
| -rw-r--r-- | doc/index.html | 2 | ||||
| -rw-r--r-- | doc/upgrade.html | 6 | ||||
| -rw-r--r-- | package/info | 2 | ||||
| -rw-r--r-- | src/server/apasted.c | 17 |
6 files changed, 32 insertions, 9 deletions
@@ -1,5 +1,11 @@ Changelog for apaste. +In 0.0.2.0 +---------- + + - New -S option to apasted. + + In 0.0.1.0 ---------- diff --git a/doc/apasted.html b/doc/apasted.html index 8840ff3..28acbd0 100644 --- a/doc/apasted.html +++ b/doc/apasted.html @@ -30,7 +30,7 @@ stored files. <h2> Interface </h2> <pre> - apasted [ -r <em>rtimeout</em> ] [ -w <em>wtimeout</em> ] [ -d <em>rootdir</em> ] [ -p <em>prefix</em> ] [ -n <em>maxfiles</em> ] [ -s <em>maxsize</em> ] + apasted [ -r <em>rtimeout</em> ] [ -w <em>wtimeout</em> ] [ -d <em>rootdir</em> ] [ -p <em>prefix</em> ] [ -n <em>maxfiles</em> ] [ -s <em>maxsize</em> ] [ -S <em>maxtotalsize</em> ] </pre> <ul> @@ -92,6 +92,12 @@ wants and apasted will still store them if it is possible. </dd> <dd> Accept a maximum of <em>maxsize</em> bytes for each file. 0 means unlimited: the files can be as big as the client wants, which is not a very good idea. The default is 1 MB. </dd> + + <dt> -S <em>maxtotalsize</em> </dt> + <dd> Accept a maximum of <em>maxtotalsize</em> bytes for a single +apaste transaction, all files included. +0 means unlimited: the transaction can be as large as the client +wants, which is not a very good idea. The default is 10 MB. </dd> </dl> <h2> Typical usage </h2> diff --git a/doc/index.html b/doc/index.html index 6697333..d10289a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@ that provides the network connection. </li> <ul> <li> The current released version of apaste is -<a href="apaste-0.0.1.0.tar.gz">0.0.1.0</a>. </li> +<a href="apaste-0.0.2.0.tar.gz">0.0.2.0</a>. </li> <li> You can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/apaste/">apaste git repository</a>: diff --git a/doc/upgrade.html b/doc/upgrade.html index c8650e5..42a4336 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,6 +18,12 @@ <h1> What has changed in apaste </h1> +<h2> in 0.0.2.0 </h2> + +<ul> + <li> New <tt>-S</tt> option to <a href="apasted.html">apasted</a>. </li> +</ul> + <h2> in 0.0.1.0 </h2> <ul> diff --git a/package/info b/package/info index 333079b..b06ac2c 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=apaste -version=0.0.1.0 +version=0.0.2.0 category=web package_macro_name=APASTE diff --git a/src/server/apasted.c b/src/server/apasted.c index a2bed17..3712190 100644 --- a/src/server/apasted.c +++ b/src/server/apasted.c @@ -27,7 +27,7 @@ #include <apaste/config.h> #include "apaste-common.h" -#define USAGE "apasted [ -r rtimeout ] [ -w wtimeout ] [ -d rootdir ] [ -p prefix ] [ -n maxfiles ] [ -s maxsize ]" +#define USAGE "apasted [ -r rtimeout ] [ -w wtimeout ] [ -d rootdir ] [ -p prefix ] [ -n maxfiles ] [ -s maxsize ] [ -S maxtotalsize ]" #define dieusage() strerr_dieusage(100, USAGE) #define FORBIDDEN " \t\r\n\"<>&;" @@ -155,7 +155,7 @@ static inline size_t add_unique (stralloc *sa, size_t *indices, uint32_t n, char return blen ; } -static void read_one_file (char const *dir, buffer *b, buffer *ib, stralloc *sa, size_t *indices, uint32_t n, uint64_t maxsize, tain const *deadline) +static void read_one_file (char const *dir, buffer *b, buffer *ib, stralloc *sa, size_t *indices, uint32_t n, uint64_t maxsize, uint64_t maxtotalsize, uint64_t *cursize, tain const *deadline) { uint64_t filelen ; size_t bnamelen ; @@ -201,7 +201,7 @@ static void read_one_file (char const *dir, buffer *b, buffer *ib, stralloc *sa, char fmt[UINT64_FMT] ; if (sanitize_read(timed_getlnmax_g(b, fmt, UINT64_FMT, &w, '\n', deadline)) <= 0) goto err ; m = uint64_scan(fmt, &filelen) ; - if (!m || m+1 != w || fmt[m] != '\n' || filelen > maxsize) goto err ; + if (!m || m+1 != w || fmt[m] != '\n' || (maxsize && filelen > maxsize) || (maxtotalsize && (filelen > maxtotalsize || *cursize + filelen > maxtotalsize))) goto err ; } { @@ -233,6 +233,8 @@ static void read_one_file (char const *dir, buffer *b, buffer *ib, stralloc *sa, if (c != '\n') goto err ; } + *cursize += filelen ; + if (ib) add_index_entry(dir, ib, sa->s + indices[n], filelen) ; return ; @@ -246,6 +248,8 @@ int main (int argc, char const *const *argv) char const *prefix = "" ; tain rtto = TAIN_INFINITE_RELATIVE, wtto = TAIN_INFINITE_RELATIVE ; tain deadline ; + uint64_t maxtotalsize = 10485760 ; + uint64_t cursize = 0 ; uint64_t maxsize = 1048576 ; uint32_t maxfiles = 0 ; uint32_t n ; @@ -259,7 +263,7 @@ int main (int argc, char const *const *argv) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "r:w:d:p:n:s:", &l) ; + int opt = subgetopt_r(argc, argv, "r:w:d:p:n:s:S:", &l) ; if (opt == -1) break ; switch (opt) { @@ -269,6 +273,7 @@ int main (int argc, char const *const *argv) case 'p' : prefix = l.arg ; break ; case 'n' : if (!uint320_scan(l.arg, &maxfiles)) dieusage() ; break ; case 's' : if (!uint640_scan(l.arg, &maxsize)) dieusage() ; break ; + case 'S' : if (!uint640_scan(l.arg, &maxtotalsize)) dieusage() ; break ; default : dieusage() ; } } @@ -304,7 +309,7 @@ int main (int argc, char const *const *argv) } if (!mkdtemp(dir)) strerr_diefu1sys(111, "mkdtemp") ; - if (n == 1) read_one_file(dir, &b, 0, 0, 0, 0, maxsize, &deadline) ; + if (n == 1) read_one_file(dir, &b, 0, 0, 0, 0, maxsize, maxtotalsize, &cursize, &deadline) ; else { stralloc sa = STRALLOC_ZERO ; @@ -312,7 +317,7 @@ int main (int argc, char const *const *argv) buffer ib ; char ibuf[4096] ; prepare_index(&ib, dir, ibuf, 4096) ; - for (uint32_t i = 0 ; i < n ; i++) read_one_file(dir, &b, &ib, &sa, indices, i, maxsize, &deadline) ; + for (uint32_t i = 0 ; i < n ; i++) read_one_file(dir, &b, &ib, &sa, indices, i, maxsize, maxtotalsize, &cursize, &deadline) ; finish_index(&ib, dir) ; } |
