aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Iliopoulos <ailiopoulos@suse.com>2020-01-16 02:15:49 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2020-01-16 12:40:54 +0100
commit11d4a3bb4a49e9f1303be072aaaceb0d27ab68e7 (patch)
tree6e6f1bf237a4b3d077670a3dd529a74007113991
parentffe6b92fd223cf56971f6d3790eb446b7f94c34c (diff)
downloadl2md-11d4a3bb4a49e9f1303be072aaaceb0d27ab68e7.tar.gz
l2md: add per-repo config option to enable or disable syncing
Introduce a config option to control the fetching/syncing on a per-repo granularity. Signed-off-by: Anthony Iliopoulos <ailiopoulos@suse.com> [ Daniel: rename to sync_enabled to make it more self-documenting and enable by default to avoid breaking existing user configs. ] Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--config.c10
-rw-r--r--l2md.h8
-rw-r--r--l2mdconfig.maildir5
3 files changed, 20 insertions, 3 deletions
diff --git a/config.c b/config.c
index e4dab04..e48baf8 100644
--- a/config.c
+++ b/config.c
@@ -118,6 +118,13 @@ static void config_set_initial_import(struct config *cfg, uint32_t limit)
repo->limit = true;
}
+static void config_set_repo_status(struct config *cfg, bool status)
+{
+ struct config_repo *repo = repo_last(cfg);
+
+ repo->sync_enabled = status;
+}
+
static void config_new_url(struct config *cfg, const char *git_url)
{
struct config_repo *repo = repo_last(cfg);
@@ -141,6 +148,7 @@ static void config_new_repo(struct config *cfg, const char *name)
repo = repo_last(cfg);
memset(repo, 0, sizeof(*repo));
config_set_out(cfg, cfg->general.out, false);
+ config_set_repo_status(cfg, true);
strlcpy(repo->name, name, sizeof(repo->name));
}
@@ -278,6 +286,8 @@ struct config *config_init(int argc, char **argv)
config_set_out(cfg, tmp, false);
} else if (sscanf(buff, "\tinitial_import = %u", &val) == 1) {
config_set_initial_import(cfg, val);
+ } else if (sscanf(buff, "\tsync_enabled = %u", &val) == 1) {
+ config_set_repo_status(cfg, val);
} else {
goto state_next;
}
diff --git a/l2md.h b/l2md.h
index 46ad443..0d99a58 100644
--- a/l2md.h
+++ b/l2md.h
@@ -65,6 +65,7 @@ struct config_repo {
uint32_t urls_num;
uint32_t initial_import;
bool limit;
+ bool sync_enabled;
};
struct config {
@@ -77,7 +78,12 @@ struct config {
#define repo_for_each(cfg, repo, i) \
for (repo = &cfg->repos[(i = 0)]; i < cfg->repos_num; \
- repo = &cfg->repos[++i])
+ repo = &cfg->repos[++i]) \
+ if (!repo->sync_enabled) { \
+ verbose("skipping disabled repo %s\n", repo->name); \
+ continue; \
+ } \
+ else
#define url_for_each(repo, url, i) \
for (url = &repo->urls[(i = 0)]; i < repo->urls_num; \
diff --git a/l2mdconfig.maildir b/l2mdconfig.maildir
index d273d9c..f10edc9 100644
--- a/l2mdconfig.maildir
+++ b/l2mdconfig.maildir
@@ -3,13 +3,14 @@
maildir = ~/.l2md/maildir/common
period = 30
-# bpf@vger.kernel.org list
+# bpf@vger.kernel.org list example with regular sync
[repo bpf]
url = https://lore.kernel.org/bpf/0
maildir = ~/.l2md/maildir/bpf
-# netdev@vger.kernel.org list
+# netdev@vger.kernel.org list example with only initial import
[repo netdev]
url = https://lore.kernel.org/netdev/1
url = https://lore.kernel.org/netdev/0
initial_import = 1000
+ sync_enabled = 0