Skip to content

Commit

Permalink
Corrected an implementation error and added more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fangfufu committed May 2, 2024
1 parent d6d4af0 commit 1a3f36a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 1a3f36a

Please sign in to comment.