added the command line switch to control the download segment size
This commit is contained in:
parent
b6b101bc63
commit
825bd4d3fb
16
README.md
16
README.md
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
# HTTPDirFS - now with a permanent cache
|
||||
Have you ever wanted to mount those HTTP directory listings as if it was a partition? Look no further, this is your solution. HTTPDirFS stands for Hyper Text Transfer Protocol Directory Filesystem
|
||||
|
||||
|
@ -13,15 +11,17 @@ The permanent cache system caches all the files you have downloaded, so you don'
|
|||
|
||||
An example URL would be [Debian CD Image Server](https://cdimage.debian.org/debian-cd/). The ``-f`` flag keeps the program in the foreground, which is useful for monitoring which URL the filesystem is visiting.
|
||||
|
||||
Other useful options:
|
||||
|
||||
Useful options:
|
||||
-f Run HTTPDirFS in foreground
|
||||
-u --username HTTP authentication username
|
||||
-p --password HTTP authentication password
|
||||
-P --proxy Proxy for libcurl, for more details refer to
|
||||
https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html
|
||||
--proxy-username Username for the proxy
|
||||
--proxy-password Password for the proxy
|
||||
--cache Set the cache folder
|
||||
https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html
|
||||
--proxy-username Username for the proxy
|
||||
--proxy-password Password for the proxy
|
||||
--cache Set the cache folder
|
||||
--dl-seg-size Set the size of each download segment in MB,
|
||||
default to 8MB
|
||||
|
||||
## Permanent cache system
|
||||
You can now cache all the files you have looked at permanently on your hard
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* \details We set it to 1024*1024*8 = 8MiB
|
||||
*/
|
||||
|
||||
#define DATA_BLK_SZ 8*1024*1024
|
||||
#define DEFAULT_DATA_BLK_SZ 8*1024*1024
|
||||
|
||||
/**
|
||||
* \brief Maximum segment block count
|
||||
|
@ -44,7 +44,9 @@ typedef enum {
|
|||
EMEM = -4, /**< Memory allocation failure */
|
||||
} MetaError;
|
||||
|
||||
|
||||
int CACHE_SYSTEM_INIT = 0;
|
||||
int DATA_BLK_SZ = 0;
|
||||
|
||||
/**
|
||||
* \brief The metadata directory
|
||||
|
@ -88,12 +90,17 @@ void CacheSystem_init(const char *path)
|
|||
fprintf(stderr, "CacheSystem_init(): mkdir(): %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (mkdir(DATA_DIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
|
||||
&& (errno != EEXIST)) {
|
||||
fprintf(stderr, "CacheSystem_init(): mkdir(): %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (!DATA_BLK_SZ) {
|
||||
DATA_BLK_SZ = DEFAULT_DATA_BLK_SZ;
|
||||
}
|
||||
|
||||
CACHE_SYSTEM_INIT = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,11 @@ typedef struct {
|
|||
*/
|
||||
extern int CACHE_SYSTEM_INIT;
|
||||
|
||||
/**
|
||||
* \brief The size of each download segment
|
||||
*/
|
||||
extern int DATA_BLK_SZ;
|
||||
|
||||
/**
|
||||
* \brief initialise the cache system directories
|
||||
* \details This function basically sets up the following variables:
|
||||
|
|
|
@ -142,6 +142,7 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
|
|||
{"proxy-username", required_argument, NULL, 'L'}, /* 6 */
|
||||
{"proxy-password", required_argument, NULL, 'L'}, /* 7 */
|
||||
{"cache", required_argument, NULL, 'L'}, /* 8 */
|
||||
{"dl-seg-size", required_argument, NULL, 'L'}, /* 9 */
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
while ((c =
|
||||
|
@ -193,6 +194,9 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
|
|||
case 8:
|
||||
CacheSystem_init(optarg);
|
||||
break;
|
||||
case 9:
|
||||
DATA_BLK_SZ = atoi(optarg) * 1024 * 1024;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Error: Invalid option\n");
|
||||
add_arg(fuse_argv, fuse_argc, "--help");
|
||||
|
@ -246,6 +250,8 @@ static void print_http_options()
|
|||
--proxy-username Username for the proxy\n\
|
||||
--proxy-password Password for the proxy\n\
|
||||
--cache Set the cache folder\n\
|
||||
--dl-seg-size Set the size of each download segment in MB, \n\
|
||||
default to 8MB\n\
|
||||
\n\
|
||||
libfuse options:\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue