From 8e07de9d952f8f27273296f1b6ae58550ce1e98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Mon, 29 Nov 2021 19:53:34 +0300 Subject: Update adjacent images to inserted/removed Now the program checks if the html of the next and previous images was updated if a new image was inserted or an old image removed, and updates them if needed. Also make rmextra and filesync respect dry run mode. --- include/components.h | 6 +++++- include/fs.h | 9 ++++++--- include/site.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/components.h b/include/components.h index e65a66a..9e568ee 100644 --- a/include/components.h +++ b/include/components.h @@ -40,9 +40,11 @@ struct image { struct hashmap *map; /* Hashmap with values to be passed to thumbs and previews vectors */ struct hashmap *thumb; + bool modified; }; struct album { + struct site *site; struct album_config *config; /* The path to the source directory */ char *source; @@ -69,11 +71,13 @@ struct album { struct image *image_new(char *src, const struct stat *, struct album *); +struct image *image_old(struct stat *istat); + int image_cmp(const void *a, const void *b); void image_destroy(void *data); -struct album *album_new(struct album_config *, struct site_config *, +struct album *album_new(struct album_config *, struct site *, const char *src, const char *rsrc, const struct stat *); int album_cmp(const void *a, const void *b); diff --git a/include/fs.h b/include/fs.h index 218958b..d48ac9f 100644 --- a/include/fs.h +++ b/include/fs.h @@ -6,6 +6,8 @@ #include "hashmap.h" +typedef bool (*preremove_fn)(const char *path, void *data); + enum nmkdir_res { NMKDIR_ERROR, NMKDIR_NOOP, @@ -49,7 +51,7 @@ int file_is_uptodate(const char *path, const struct timespec *srcmtim); */ void setdatetime(const char *path, const struct timespec *mtim); -bool rmentry(const char *path); +bool rmentry(const char *path, bool dry); /* * Recursively deletes extaneous files from directory, keeping files in the @@ -57,7 +59,8 @@ bool rmentry(const char *path); * The number is not the total number of files on all subdirectories, but only * the number of files/dirs deleted from the directory pointed by path. */ -ssize_t rmextra(const char *path, struct hashmap *preserved); +ssize_t rmextra(const char *path, struct hashmap *preserved, preremove_fn, + void *data, bool dry); /* * Copies file(s) truncating and overwritting the file(s) in the destination @@ -67,6 +70,6 @@ ssize_t rmextra(const char *path, struct hashmap *preserved); * timestamps do not match. */ bool filesync(const char *restrict srcpath, const char *restrict dstpath, - struct hashmap *preserved); + struct hashmap *preserved, bool dry); #endif diff --git a/include/site.h b/include/site.h index 6ddac82..db82517 100644 --- a/include/site.h +++ b/include/site.h @@ -34,6 +34,7 @@ struct site { struct hashmap *album_dirs; struct render render; bool dry_run; + size_t albums_updated; }; bool site_build(struct site *); -- cgit v1.2.3