Wed, 13 Mar 2019 18:43:30 +0100
adds metadata config element for dav-sync
dav/db.c | file | annotate | diff | comparison | revisions | |
dav/db.h | file | annotate | diff | comparison | revisions | |
dav/finfo.c | file | annotate | diff | comparison | revisions | |
dav/finfo.h | file | annotate | diff | comparison | revisions | |
dav/main.c | file | annotate | diff | comparison | revisions | |
dav/scfg.c | file | annotate | diff | comparison | revisions | |
dav/scfg.h | file | annotate | diff | comparison | revisions | |
dav/sync.c | file | annotate | diff | comparison | revisions |
--- a/dav/db.c Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/db.c Wed Mar 13 18:43:30 2019 +0100 @@ -329,7 +329,7 @@ } } - if(settings & DB_STORE_USER == DB_STORE_USER) { + if(settings & DB_STORE_OWNER == DB_STORE_OWNER) { r = xmlTextWriterWriteFormatElement( writer, BAD_CAST "uid",
--- a/dav/db.h Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/db.h Wed Mar 13 18:43:30 2019 +0100 @@ -41,8 +41,8 @@ extern "C" { #endif -#define DB_STORE_MODE 1 -#define DB_STORE_USER 2 +#define DB_STORE_MODE 1 +#define DB_STORE_OWNER 2 typedef struct LocalResource LocalResource; typedef struct SyncDatabase SyncDatabase;
--- a/dav/finfo.c Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/finfo.c Wed Mar 13 18:43:30 2019 +0100 @@ -40,7 +40,7 @@ #include "libxattr.h" -uint32_t parse_finfo(const char *str) { +uint32_t parse_finfo(const char *str, char **error) { scstr_t s = scstr(str); if(!sstrcmp(s, SC("*")) || !sstrcmp(s, SC("a")) || !sstrcmp(s, SC("all"))) { @@ -50,6 +50,8 @@ size_t count = 0; sstr_t *fs = sstrsplit(s, SC(","), &count); + char *err = NULL; + uint32_t finfo = 0; for(int i=0;i<count;i++) { sstr_t f = fs[i]; @@ -61,12 +63,15 @@ finfo |= FINFO_MODE; } else if(!sstrcasecmp(f, SC("xattr"))) { finfo |= FINFO_XATTR; + } else if(error && !err) { + err = fs[i].ptr; + continue; } free(f.ptr); } free(fs); - return finfo; + return err ? 0 : finfo; } int resource_set_finfo(const char *path, DavResource *res, uint32_t finfo) {
--- a/dav/finfo.h Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/finfo.h Wed Mar 13 18:43:30 2019 +0100 @@ -49,7 +49,7 @@ char *hash; } XAttributes; -uint32_t parse_finfo(const char *str); +uint32_t parse_finfo(const char *str, char **unknown); int resource_set_finfo(const char *path, DavResource *res, uint32_t finfo); int resource_set_finfo_s(struct stat *s, DavResource *res, uint32_t finfo);
--- a/dav/main.c Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/main.c Wed Mar 13 18:43:30 2019 +0100 @@ -1259,7 +1259,7 @@ char *finfo_str = cmd_getoption(a, "finfo"); uint32_t finfo = 0; if(finfo_str) { - finfo = parse_finfo(finfo_str); + finfo = parse_finfo(finfo_str, NULL); } int ret;
--- a/dav/scfg.c Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/scfg.c Wed Mar 13 18:43:30 2019 +0100 @@ -36,6 +36,7 @@ #include "scfg.h" #include "config.h" +#include "finfo.h" #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b) @@ -306,6 +307,7 @@ bool lockpull = false; bool lockpush = false; time_t lock_timeout = 0; + uint32_t metadata = 0; unsigned short parentlineno = node->line; node = node->children; @@ -340,6 +342,13 @@ database = value; } else if(xstreq(node->name, "tagconfig")) { tagconfig = parse_tagconfig(node); + } else if(xstreq(node->name, "metadata")) { + char *error = NULL; + metadata = parse_finfo(value, &error); + if(error) { + print_error(node->line, "unknown metadata: %s\n", error); + free(error); + } } else if(xstreq(node->name, "versioning")) { versioning = parse_versioning_config(node); } else if(xstreq(node->name, "max-retry")) { @@ -427,6 +436,14 @@ dir->lockpull = lockpull; dir->lockpush = lockpush; dir->lock_timeout = lock_timeout; + dir->metadata = metadata; + if(metadata & FINFO_MODE == FINFO_MODE) { + dir->db_settings = DB_STORE_MODE; + } + if(metadata & FINFO_OWNER == FINFO_OWNER) { + dir->db_settings |= DB_STORE_OWNER; + } + if (include) { dir->include = include; } else {
--- a/dav/scfg.h Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/scfg.h Wed Mar 13 18:43:30 2019 +0100 @@ -64,6 +64,7 @@ UcxList *include; UcxList *exclude; UcxList *tagfilter; + uint32_t metadata; int max_retry; int allow_cmd; time_t lock_timeout;
--- a/dav/sync.c Wed Mar 13 15:05:40 2019 +0100 +++ b/dav/sync.c Wed Mar 13 18:43:30 2019 +0100 @@ -1682,12 +1682,18 @@ res->etag = NULL; res->last_modified = s.st_mtime; res->size = s.st_size; + res->mode = s.st_mode & 07777; + res->uid = s.st_uid; + res->gid = s.st_gid; return res; } else { *isdir = 1; LocalResource *res = calloc(1, sizeof(LocalResource)); res->path = util_concat_path(path, "/"); res->last_modified = s.st_mtime; + res->mode = s.st_mode & 07777; + res->uid = s.st_uid; + res->gid = s.st_gid; res->isdirectory = 1; return res; } @@ -2122,7 +2128,7 @@ int versioning_begin(SyncDirectory *dir, DavResource *res, int *exists) { int ret = 0; - if(dir->versioning->type == VERSIONING_SIMPLE) { + if(dir->versioning->type == VERSIONING_SIMPLE && *exists) { DavResource *history_collection = dav_resource_new( res->session, dir->versioning->collection); @@ -2217,7 +2223,7 @@ } dav_resource_free(history_collection); - } else { + } else if(dir->versioning->type == VERSIONING_DELTAV){ // DeltaV is so much easier :) if(dav_checkout(res)) { ret = VBEGIN_ERROR_CHECKOUT; @@ -2239,6 +2245,7 @@ if(dir->versioning->type == VERSIONING_SIMPLE) { // TODO } + return 0; } int sync_put_resource(