aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-29 19:53:34 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-29 19:53:34 +0300
commit8e07de9d952f8f27273296f1b6ae58550ce1e98b (patch)
treec653d6d2b4a2e2251ce0ff44ad4740d91e20b1da /include
parentef0a23b0636a8c7f4a3c802ff76645261e8b225f (diff)
downloadrevela-8e07de9d952f8f27273296f1b6ae58550ce1e98b.tar.gz
revela-8e07de9d952f8f27273296f1b6ae58550ce1e98b.zip
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.
Diffstat (limited to 'include')
-rw-r--r--include/components.h6
-rw-r--r--include/fs.h9
-rw-r--r--include/site.h1
3 files changed, 12 insertions, 4 deletions
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 *);