From cf1d46edf40417e6fff4ba7b0eb7f23b4d9b9300 Mon Sep 17 00:00:00 2001 From: Fufu Fang Date: Thu, 24 Oct 2019 02:19:42 +0100 Subject: [PATCH] fixed regression - cache system stopped working on regular http server updated readme / help Update README.md Update README.md --- CHANGELOG.md | 10 ++++++++-- Makefile | 2 +- README.md | 23 +++++++++++++++++++++-- src/cache.c | 10 +++++----- src/main.c | 7 +++++-- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a42ff..a96a149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [1.2.0] - 2019-10-24 +### Added +- Subsonic server support - this is dedicated to my Debian package maintainer +Jerome Charaoui + ### Changed - Wrapped all calloc() calls with error handling functions. +- Various code refactoring + +### Fixed - Remove the erroneous error messages when the user supplies wrong command line options. -- Separated out network initialisation code and root LinkTable retrieval code. ## [1.1.10] - 2019-09-10 ### Added diff --git a/Makefile b/Makefile index 35e2809..33bae3d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=1.1.10 +VERSION=1.2.0 CFLAGS+= -O2 -Wall -Wextra -Wshadow\ -rdynamic -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_GNU_SOURCE\ diff --git a/README.md b/README.md index b060266..ab65812 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# HTTPDirFS - HTTP Directory Filesystem, with a permanent cache +# HTTPDirFS - HTTP Directory Filesystem 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. @@ -11,9 +12,12 @@ downloaded, so you don't need to these segments again if you access them later. This feature is triggered by the ``--cache`` flag. This makes this filesystem much faster than ``rclone mount``. +## News +HTTPDirFS now supports mounting Airsonic / Subsonic servers + ## Usage - ./httpdirfs -f --cache $URL $YOUR_MOUNT_POINT + ./httpdirfs -f --cache $URL $MOUNT_POINT An example URL would be [Debian CD Image Server](https://cdimage.debian.org/debian-cd/). The ``-f`` flag @@ -47,6 +51,10 @@ HTTPDirFS options: after encountering an error. (default: 5) --user-agent Set user agent string (default: "HTTPDirFS") +Subsonic options: + --sonic-username The username for your Airsonic / Subsonic server + --sonic-password The username for your Airsonic / Subsonic server + FUSE options: -d -o debug enable debug output (implies -f) @@ -77,6 +85,17 @@ filesystem supports it. Otherwise your hard drive / SSD will get heavy I/O from cache file creation. For a list of filesystem that supports sparse allocation, please refer to [Wikipedia](https://en.wikipedia.org/wiki/Comparison_of_file_systems#Allocation_and_layout_policies). +## Airsonic / Subsonic server support +This is a new feature to 1.2.0. Now you can mount the music collection on your +Airsonic / Subsonic server, and browse them using your favourite file browser. +You simply have to supply both ``--sonic-username`` and ``--sonic-password`` to +trigger the Airsonic / Subsonic server mode. For example: + + ./httpdirfs -f --cache --sonic-username $USERNAME --sonic-password $PASSWORD $URL $MOUNT_POINT + +You definitely want to enable the cache for this one, otherwise it is painfully +slow. + ## Configuration file support This program has basic support for using a configuration file. The configuration file that the program reads is ``${XDG_CONFIG_HOME}/httpdirfs/config``, which by diff --git a/src/cache.c b/src/cache.c index 03c140f..b7221ab 100644 --- a/src/cache.c +++ b/src/cache.c @@ -782,11 +782,12 @@ Cache *Cache_open(const char *fn) /* Create the cache in-memory data structure */ Cache *cf = Cache_alloc(); + /* Fill in the fs_path */ + cf->fs_path = calloc(MAX_PATH_LEN + 1, sizeof(char)); + strncpy(cf->fs_path, fn, MAX_PATH_LEN); + + /* Set the path for the local cache file, if we are in sonic mode */ if (CONFIG.sonic_mode) { - /* Fill in the fs_path */ - cf->fs_path = calloc(MAX_PATH_LEN + 1, sizeof(char)); - strncpy(cf->fs_path, fn, MAX_PATH_LEN); - /* Set the path for the local cache file */ fn = link->sonic_id_str; } @@ -1007,7 +1008,6 @@ long Cache_read(Cache *cf, char * const output_buf, const off_t len, uint8_t *recv_buf = CALLOC(cf->blksz, sizeof(uint8_t)); fprintf(stderr, "Cache_read(): thread %lu: ", pthread_self()); - fprintf(stderr, "cf->fs_path: %s\n", cf->fs_path); long recv = path_download(cf->fs_path, (char *) recv_buf, cf->blksz, dl_offset); if (recv < 0) { diff --git a/src/main.c b/src/main.c index 93d0ca2..5ae118d 100644 --- a/src/main.c +++ b/src/main.c @@ -296,6 +296,9 @@ HTTPDirFS options:\n\ --retry-wait Set delay in seconds before retrying an HTTP request\n\ after encountering an error. (default: 5)\n\ --user-agent Set user agent string (default: \"HTTPDirFS\")\n\ -\n\ -"); + + For mounting a Airsonic / Subsonic server:\n\ + --sonic-username The username for your Airsonic / Subsonic server\n\ + --sonic-password The username for your Airsonic / Subsonic server\n\ +\n\"); }