Skip to content

Commit 1a3f36a

Browse files
committed
Corrected an implementation error and added more comments
1 parent d6d4af0 commit 1a3f36a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/link.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,17 +722,15 @@ LinkTable *LinkTable_disk_open(const char *dirn)
722722
FREE(metadirn);
723723

724724
if (!fp) {
725+
lprintf(debug, "Linktable at %s does not exist.", path);
725726
FREE(path);
726727
return NULL;
727728
}
728729

729730
LinkTable *linktbl = CALLOC(1, sizeof(LinkTable));
730731

731-
if (sizeof(int) != fread(&linktbl->num, sizeof(int), 1, fp)) {
732-
/*
733-
* reached EOF
734-
*/
735-
lprintf(error, "reached EOF!\n");
732+
if (fread(&linktbl->num, sizeof(int), 1, fp) != 1) {
733+
lprintf(error, "Failed to read the first int of %s!\n", path);
736734
LinkTable_free(linktbl);
737735
LinkTable_disk_delete(dirn);
738736
return NULL;

src/link.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct LinkTable {
4343
struct Link {
4444
/** \brief The link name in the last level of the URL */
4545
char linkname[MAX_FILENAME_LEN + 1];
46+
/** \brief This is for storing the unescaped path */
4647
char linkpath[MAX_FILENAME_LEN + 1];
4748
/** \brief The full URL of the file */
4849
char f_url[MAX_PATH_LEN + 1];
@@ -116,6 +117,7 @@ int LinkTable_disk_save(LinkTable *linktbl, const char *dirn);
116117

117118
/**
118119
* \brief load a link table from the disk.
120+
* \param[in] dirn We expected the unescaped_path here!
119121
*/
120122
LinkTable *LinkTable_disk_open(const char *dirn);
121123

0 commit comments

Comments
 (0)