Introduce astcachedir, to be used for temporary bucket files

As described in the issue, /tmp is not a suitable location for a
large amount of cached media files, since most distributions make
/tmp a RAM-based tmpfs mount with limited capacity.

I opted for a location that can be configured separately, as opposed
to using a subdirectory of spooldir, given the different storage
profile (transient files vs files that might stay there indefinitely).

This commit just makes the cache directory configurable, but leaves
it at /tmp by default, to ensure backwards compatibility.

A future commit that only targets master could change the default
location to something more sensible such as /var/tmp/asterisk. At
that point, the cachedir could be created and cleaned up during
uninstall by the Makefile script.

ASTERISK-29143

Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d
This commit is contained in:
lvl
2020-10-29 12:25:27 +01:00
committed by George Joseph
parent f39d5ea7cd
commit 92fcd4edba
13 changed files with 31 additions and 4 deletions

View File

@@ -73,6 +73,7 @@
#include "asterisk/json.h"
#include "asterisk/file.h"
#include "asterisk/module.h"
#include "asterisk/paths.h"
/*! \brief Number of buckets for the container of schemes */
#define SCHEME_BUCKETS 53
@@ -899,7 +900,7 @@ int ast_bucket_file_temporary_create(struct ast_bucket_file *file)
{
int fd;
ast_copy_string(file->path, "/tmp/bucket-XXXXXX", sizeof(file->path));
snprintf(file->path, sizeof(file->path), "%s/bucket-XXXXXX", ast_config_AST_CACHE_DIR);
fd = mkstemp(file->path);
if (fd < 0) {