return 1;
}
+static int td_source_check_num_ds(td_source* self, const char* path, rrd_info_t* info, int index) {
+ int i = 0;
+
+ for (; info; info = info->next) {
+ // Skip if the key does not start with "ds["
+ if (!td_string_startswith(info->key, "ds["))
+ continue;
+
+ // Skip if the key does not end with "].index"
+ if (!td_string_endswith(info->key, "].index"))
+ continue;
+
+ // Need to migrate if we have more DS than we should have
+ if (index <= i++) {
+ DEBUG(self->ctx, "%s: We have some extra DS and need to migrate\n", path);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static int td_source_needs_migration(td_source* self, const char* path, rrd_info_t* info) {
unsigned long index = 0;
int r;
return r;
}
+ // Check if we have some extra DSs
+ r = td_source_check_num_ds(self, path, info, index);
+ if (r)
+ return r;
+
// XXX Check RRAs
return 0;
return !strncmp(s, prefix, strlen(prefix));
}
+static inline int td_string_endswith(const char* s, const char* suffix) {
+ // Validate input
+ if (!s || !suffix)
+ return -EINVAL;
+
+ return !strcmp(s + strlen(s) - strlen(suffix), suffix);
+}
+
static inline void td_string_lstrip(char* s) {
if (!s)
return;