Change error handling in cache.c, Updated Changelog.md
This commit is contained in:
parent
a459dc926f
commit
5e87ac92b0
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.2.3] - 2021-08-31
|
||||
|
||||
### Added
|
||||
- Single File Mode, which allows the mounting of a single file in a virtual
|
||||
directory
|
||||
- man page generation in Makefile.
|
||||
|
||||
### Changed
|
||||
- Improve log / debug output.
|
||||
- Removed unnecessary mutex lock/unlocks.
|
||||
|
||||
### Fixed
|
||||
- Handling empty files
|
||||
|
||||
## [1.2.2] - 2021-08-08
|
||||
### Fixed
|
||||
- macOS uninstallation in Makefile.
|
||||
|
@ -186,7 +200,8 @@ ${XDG_CONFIG_HOME}/httpdirfs, rather than ${HOME}/.httpdirfs
|
|||
## [1.0] - 2018-08-22
|
||||
- Initial release, everything works correctly, as far as I know.
|
||||
|
||||
[Unreleased]: https://github.com/fangfufu/httpdirfs/compare/1.2.2...master
|
||||
[Unreleased]: https://github.com/fangfufu/httpdirfs/compare/1.2.3...master
|
||||
[1.2.2]: https://github.com/fangfufu/httpdirfs/compare/1.2.2...1.2.3
|
||||
[1.2.2]: https://github.com/fangfufu/httpdirfs/compare/1.2.1...1.2.2
|
||||
[1.2.1]: https://github.com/fangfufu/httpdirfs/compare/1.2.0...1.2.1
|
||||
[1.2.0]: https://github.com/fangfufu/httpdirfs/compare/1.1.10...1.2.0
|
||||
|
|
10
Makefile
10
Makefile
|
@ -24,7 +24,7 @@ endif
|
|||
|
||||
prefix ?= /usr/local
|
||||
|
||||
all: man
|
||||
all: httpdirfs
|
||||
|
||||
%.o: src/%.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $@ $<
|
||||
|
@ -61,13 +61,17 @@ man: httpdirfs
|
|||
doc:
|
||||
doxygen Doxyfile
|
||||
|
||||
format:
|
||||
indent -kr -nut src/*.c src/*.h
|
||||
|
||||
clean:
|
||||
-rm -f src/*.h~ src/*.c~
|
||||
-rm -f *.o
|
||||
-rm -f httpdirfs
|
||||
-rm -rf doc/man/httpdirfs.1
|
||||
|
||||
distclean: clean
|
||||
-rm -rf doc/html
|
||||
-rm -rf doc/man/httpdirfs.1
|
||||
|
||||
uninstall:
|
||||
-rm -f $(DESTDIR)$(prefix)/bin/httpdirfs
|
||||
|
@ -87,4 +91,4 @@ depend: .depend
|
|||
$(CC) $(CFLAGS) -MM $^ -MF ./.depend;
|
||||
include .depend
|
||||
|
||||
.PHONY: all man doc install clean distclean uninstall depend
|
||||
.PHONY: all man doc install clean distclean uninstall depend format
|
||||
|
|
22
src/cache.c
22
src/cache.c
|
@ -172,9 +172,11 @@ static int Meta_read(Cache * cf)
|
|||
return EIO;
|
||||
}
|
||||
|
||||
if (!cf->blksz) {
|
||||
/* These things really should not be zero!!! */
|
||||
if (!cf->content_length || !cf->blksz || !cf->segbc) {
|
||||
lprintf(error,
|
||||
"corrupt metadata: %s, blksz: %d", cf->path, cf->blksz);
|
||||
"corruption: content_length: %ld, blksz: %d, segbc: %ld\n",
|
||||
cf->content_length, cf->blksz, cf->segbc);
|
||||
return EBADMSG;
|
||||
}
|
||||
|
||||
|
@ -254,8 +256,8 @@ static int Meta_write(Cache * cf)
|
|||
* These things really should not be zero!!!
|
||||
*/
|
||||
if (!cf->content_length || !cf->blksz || !cf->segbc) {
|
||||
lprintf(error, "Warning: content_length: %ld, blksz: %d, segbc: \
|
||||
%ld\n", cf->content_length, cf->blksz, cf->segbc);
|
||||
lprintf(error, "content_length: %ld, blksz: %d, segbc: %ld\n",
|
||||
cf->content_length, cf->blksz, cf->segbc);
|
||||
}
|
||||
|
||||
fwrite(&cf->time, sizeof(long), 1, fp);
|
||||
|
@ -264,6 +266,8 @@ static int Meta_write(Cache * cf)
|
|||
fwrite(&cf->segbc, sizeof(long), 1, fp);
|
||||
if (cf->segbc > 0) {
|
||||
fwrite(cf->seg, sizeof(Seg), cf->segbc, fp);
|
||||
} else {
|
||||
lprintf(error, "cg->seg <= 0!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -672,9 +676,7 @@ int Cache_create(const char *path)
|
|||
this_link->f_url + ROOT_LINK_OFFSET, 0,
|
||||
NULL);
|
||||
} else if (CONFIG.mode == SINGLE) {
|
||||
fn = curl_easy_unescape(NULL,
|
||||
this_link->linkname, 0,
|
||||
NULL);
|
||||
fn = curl_easy_unescape(NULL, this_link->linkname, 0, NULL);
|
||||
} else if (CONFIG.mode == SONIC) {
|
||||
fn = this_link->sonic_id;
|
||||
} else {
|
||||
|
@ -990,8 +992,7 @@ Cache_read(Cache * cf, char *const output_buf, const off_t len,
|
|||
off_t dl_offset = (offset_start + len) / cf->blksz * cf->blksz;
|
||||
|
||||
/*
|
||||
* ------------------ Check if the segment already exists
|
||||
* ---------------
|
||||
* ------------- Check if the segment already exists --------------
|
||||
*/
|
||||
if (Seg_exist(cf, dl_offset)) {
|
||||
send = Data_read(cf, (uint8_t *) output_buf, len, offset_start);
|
||||
|
@ -1022,8 +1023,7 @@ Cache_read(Cache * cf, char *const output_buf, const off_t len,
|
|||
}
|
||||
|
||||
/*
|
||||
* ------------------------Download the segment
|
||||
* -------------------------
|
||||
* ------------------ Download the segment ---------------------
|
||||
*/
|
||||
|
||||
uint8_t *recv_buf = CALLOC(cf->blksz, sizeof(uint8_t));
|
||||
|
|
|
@ -22,7 +22,7 @@ static void *fs_init(struct fuse_conn_info *conn)
|
|||
/** \brief release an opened file */
|
||||
static int fs_release(const char *path, struct fuse_file_info *fi)
|
||||
{
|
||||
lprintf(info, "%s\n", path);
|
||||
lprintf(info, "%s\n", path);
|
||||
(void) path;
|
||||
if (CACHE_SYSTEM_INIT) {
|
||||
Cache_close((Cache *) fi->fh);
|
||||
|
@ -90,7 +90,7 @@ fs_read(const char *path, char *buf, size_t size, off_t offset,
|
|||
/** \brief open a file indicated by the path */
|
||||
static int fs_open(const char *path, struct fuse_file_info *fi)
|
||||
{
|
||||
lprintf(info, "%s\n", path);
|
||||
lprintf(info, "%s\n", path);
|
||||
Link *link = path_to_Link(path);
|
||||
if (!link) {
|
||||
return -ENOENT;
|
||||
|
|
|
@ -345,7 +345,7 @@ void Link_set_file_stat(Link * this_link, CURL * curl)
|
|||
double cl = 0;
|
||||
curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
|
||||
curl_easy_getinfo(curl, CURLINFO_FILETIME, &(this_link->time));
|
||||
if (cl == -1) {
|
||||
if (cl < 0) {
|
||||
this_link->type = LINK_INVALID;
|
||||
} else {
|
||||
this_link->type = LINK_FILE;
|
||||
|
|
|
@ -45,7 +45,7 @@ log_printf(LogType type, const char *file, const char *func, int line,
|
|||
print_actual_message:
|
||||
{
|
||||
}
|
||||
fprintf(stderr, "%s: ", func);
|
||||
fprintf(stderr, "%s: ", func);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
|
@ -66,4 +66,4 @@ void print_version()
|
|||
*/
|
||||
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
|
||||
lprintf(info, "libcurl SSL engine: %s\n", data->ssl_version);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,4 @@ void log_printf(LogType type, const char *file, const char *func, int line,
|
|||
/**
|
||||
* \brief Print the version information for HTTPDirFS
|
||||
*/
|
||||
void print_version();
|
||||
void print_version();
|
||||
|
|
12
src/util.c
12
src/util.c
|
@ -140,12 +140,12 @@ void *CALLOC(size_t nmemb, size_t size)
|
|||
|
||||
void FREE(void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
} else {
|
||||
lprintf(fatal, "attempted to double free a pointer!\n");
|
||||
}
|
||||
if (ptr) {
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
} else {
|
||||
lprintf(fatal, "attempted to double free a pointer!\n");
|
||||
}
|
||||
}
|
||||
|
||||
char *str_to_hex(char *s)
|
||||
|
|
Loading…
Reference in New Issue