From 9ef835721a72b78849a2d902efa92a3bbdb68f27 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 29 Jul 2009 22:26:10 +0200 Subject: [PATCH] seems to work:!!! --- bacula/src/cats/protos.h | 1 + bacula/src/cats/sql_create.c | 20 ++++++++++++++++++-- bacula/src/dird/catreq.c | 16 ++++------------ bacula/src/filed/accurate.c | 15 +++++++-------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index 9801674f6d..43cb8fbb3c 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -143,6 +143,7 @@ int db_update_stats(JCR *jcr, B_DB *mdb, utime_t age); +bool db_create_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar); bool db_create_base_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar); bool db_commit_base_file_attributes_record(JCR *jcr, B_DB *mdb); void db_cleanup_base_file(JCR *jcr, B_DB *mdb); diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 91e8e376f1..7e96b1eb0b 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -1133,6 +1133,21 @@ const char *create_temp_basefile[4] = { "Name TEXT)" }; +/* + * Create file attributes record, or base file attributes record + */ +bool db_create_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) +{ + bool ret; + if (ar->FileType == FT_BASE) { + ret = db_create_base_file_attributes_record(jcr, mdb, ar); + } else { + ret = db_create_file_attributes_record(jcr, mdb, ar); + } + + return ret; +} + /* * Create Base File record in B_DB * @@ -1165,7 +1180,8 @@ bool db_create_base_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) Mmsg(mdb->cmd, "INSERT INTO basefile%lld (Path, Name) VALUES ('%s','%s')", (uint64_t)jcr->JobId, mdb->esc_path, mdb->esc_name); - + Dmsg1(0, "%s\n", mdb->cmd); + ret = INSERT_DB(jcr, mdb, mdb->cmd); db_unlock(mdb); @@ -1188,7 +1204,7 @@ bool db_commit_base_file_attributes_record(JCR *jcr, B_DB *mdb) "AND A.Name = B.Name " "ORDER BY B.FileId)", edit_uint64(jcr->JobId, ed1), ed1, ed1); - + Dmsg1(0, "%s\n", buf.c_str()); return db_sql_query(mdb, buf.c_str(), NULL, NULL); } diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index e9a180b75d..cf1dee5836 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -404,7 +404,7 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) if (Stream == STREAM_UNIX_ATTRIBUTES || Stream == STREAM_UNIX_ATTRIBUTES_EX) { if (jcr->cached_attribute) { Dmsg2(400, "Cached attr. Stream=%d fname=%s\n", ar->Stream, ar->fname); - if (!db_create_file_attributes_record(jcr, jcr->db, ar)) { + if (!db_create_attributes_record(jcr, jcr->db, ar)) { Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db)); } } @@ -415,6 +415,7 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) skip_nonspaces(&p); /* skip FileIndex */ skip_spaces(&p); ar->FileType = str_to_int32(p); /* TODO: choose between unserialize and str_to_int32 */ + Dmsg1(0, "FileType=%i\n", ar->FileType); skip_nonspaces(&p); /* skip FileType */ skip_spaces(&p); fname = p; @@ -487,19 +488,10 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) ar->Stream, ar->fname); /* Update BaseFile table */ - if (ar->FileType == FT_BASE) { - if (!db_create_base_file_attributes_record(jcr, jcr->db, ar)) { - Jmsg1(jcr, M_FATAL, 0, _("Base attribute create error. %s"), + if (!db_create_attributes_record(jcr, jcr->db, ar)) { + Jmsg1(jcr, M_FATAL, 0, _("attribute create error. %s"), db_strerror(jcr->db)); - } - - } else { /* Regular files */ - if (!db_create_file_attributes_record(jcr, jcr->db, ar)) { - Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), - db_strerror(jcr->db)); - } } - jcr->cached_attribute = false; } else { if (!db_add_digest_to_file_record(jcr, jcr->db, ar->FileId, digestbuf, type)) { diff --git a/bacula/src/filed/accurate.c b/bacula/src/filed/accurate.c index 9e63ed3ae6..deae8aac56 100644 --- a/bacula/src/filed/accurate.c +++ b/bacula/src/filed/accurate.c @@ -110,15 +110,14 @@ static bool accurate_send_base_file_list(JCR *jcr) ff_pkt->type = FT_BASE; foreach_htable(elt, jcr->file_list) { - if (!elt->seen || !plugin_check_file(jcr, elt->fname)) { - continue; + if (elt->seen) { + Dmsg2(0, "base file fname=%s seen=%i\n", elt->fname, elt->seen); + ff_pkt->fname = elt->fname; + ff_pkt->statp.st_mtime = elt->mtime; + ff_pkt->statp.st_ctime = elt->ctime; + encode_and_send_attributes(jcr, ff_pkt, stream); +// free(elt->fname); } - Dmsg2(dbglvl, "base file fname=%s seen=%i\n", elt->fname, elt->seen); - ff_pkt->fname = elt->fname; - ff_pkt->statp.st_mtime = elt->mtime; - ff_pkt->statp.st_ctime = elt->ctime; - encode_and_send_attributes(jcr, ff_pkt, stream); -// free(elt->fname); } term_find_files(ff_pkt); -- 2.39.5