Corrected an implementation error and added more comments

This commit is contained in:
Fufu Fang 2024-05-02 04:40:24 +01:00
parent d6d4af0c8c
commit 1a3f36a92c
No known key found for this signature in database
GPG Key ID: 8A4CB08B0A7E27CE
2 changed files with 5 additions and 5 deletions

View File

@ -722,17 +722,15 @@ LinkTable *LinkTable_disk_open(const char *dirn)
FREE(metadirn);
if (!fp) {
lprintf(debug, "Linktable at %s does not exist.", path);
FREE(path);
return NULL;
}
LinkTable *linktbl = CALLOC(1, sizeof(LinkTable));
if (sizeof(int) != fread(&linktbl->num, sizeof(int), 1, fp)) {
/*
* reached EOF
*/
lprintf(error, "reached EOF!\n");
if (fread(&linktbl->num, sizeof(int), 1, fp) != 1) {
lprintf(error, "Failed to read the first int of %s!\n", path);
LinkTable_free(linktbl);
LinkTable_disk_delete(dirn);
return NULL;

View File

@ -43,6 +43,7 @@ struct LinkTable {
struct Link {
/** \brief The link name in the last level of the URL */
char linkname[MAX_FILENAME_LEN + 1];
/** \brief This is for storing the unescaped path */
char linkpath[MAX_FILENAME_LEN + 1];
/** \brief The full URL of the file */
char f_url[MAX_PATH_LEN + 1];
@ -116,6 +117,7 @@ int LinkTable_disk_save(LinkTable *linktbl, const char *dirn);
/**
* \brief load a link table from the disk.
* \param[in] dirn We expected the unescaped_path here!
*/
LinkTable *LinkTable_disk_open(const char *dirn);