From: Adam Dickmeiss Date: Sun, 3 Dec 2006 16:05:13 +0000 (+0000) Subject: Fixed bug #739: Extended service update fails with Alvis filter. X-Git-Tag: ZEBRA.2.0.8~62 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=08b7c1004e499046730ef564c901cc3b584d6e1f Fixed bug #739: Extended service update fails with Alvis filter. This change makes it possible to have register and shadow as same directory. The size limits is only counted for each file type (so if shadow is 10M and register is 20M the total size of directory is 30M). --- diff --git a/bfile/bfile.c b/bfile/bfile.c index 1f6f49d..bd1fe92 100644 --- a/bfile/bfile.c +++ b/bfile/bfile.c @@ -1,4 +1,4 @@ -/* $Id: bfile.c,v 1.52 2006-11-14 08:12:06 adam Exp $ +/* $Id: bfile.c,v 1.53 2006-12-03 16:05:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -55,7 +55,7 @@ struct BFile_struct struct BFiles_struct { MFile_area commit_area; - MFile_area_struct *register_area; + MFile_area register_area; char *base; char *cache_fname; }; @@ -68,7 +68,7 @@ BFiles bfs_create (const char *spec, const char *base) bfs->cache_fname = 0; if (base) bfs->base = xstrdup(base); - bfs->register_area = mf_init("register", spec, base); + bfs->register_area = mf_init("register", spec, base, 0); if (!bfs->register_area) { bfs_destroy(bfs); @@ -108,7 +108,7 @@ ZEBRA_RES bf_cache(BFiles bfs, const char *spec) { yaz_log(YLOG_LOG, "enabling shadow spec=%s", spec); if (!bfs->commit_area) - bfs->commit_area = mf_init("shadow", spec, bfs->base); + bfs->commit_area = mf_init("shadow", spec, bfs->base, 1); if (bfs->commit_area) { bfs->cache_fname = xmalloc(strlen(bfs->commit_area->dirs->name)+ diff --git a/bfile/mfile.c b/bfile/mfile.c index b55dc2e..dfbfadd 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -1,4 +1,4 @@ -/* $Id: mfile.c,v 1.71 2006-11-14 08:12:06 adam Exp $ +/* $Id: mfile.c,v 1.72 2006-12-03 16:05:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -192,7 +192,8 @@ static int cmp_part_file(const void *p1, const void *p2) return 0; } -MFile_area mf_init(const char *name, const char *spec, const char *base) +MFile_area mf_init(const char *name, const char *spec, const char *base, + int only_shadow_files) { MFile_area ma = (MFile_area) xmalloc(sizeof(*ma)); mf_dir *dirp; @@ -236,6 +237,11 @@ MFile_area mf_init(const char *name, const char *spec, const char *base) memcpy(metaname, dent->d_name, cp - dent->d_name); metaname[ cp - dent->d_name] = '\0'; + /* only files such as file-i-0.mf and file-i-b-0.mf, bug #739 */ + if (only_shadow_files && cp[-2] != '-') + continue; + if (!only_shadow_files && cp[-2] == '-') + continue; for (meta_f = ma->mfiles; meta_f; meta_f = meta_f->next) { /* known metafile */ diff --git a/bfile/mfile.h b/bfile/mfile.h index cfa408f..8fcae07 100644 --- a/bfile/mfile.h +++ b/bfile/mfile.h @@ -1,4 +1,4 @@ -/* $Id: mfile.h,v 1.10 2006-11-14 12:41:19 adam Exp $ +/* $Id: mfile.h,v 1.11 2006-12-03 16:05:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -106,11 +106,13 @@ typedef struct MFile_area_struct \param name of area (does not show up on disk - purely for notation) \param spec area specification (e.g. "/a:1G dir /b:2000M" \param base base directory (NULL for no base) + \param only_shadow_files only consider shadow files in area \returns metafile area handle or NULL if error occurs */ -MFile_area mf_init(const char *name, const char *spec, const char *base) +MFile_area mf_init(const char *name, const char *spec, const char *base, + int only_shadow_files) ZEBRA_GCC_ATTR((warn_unused_result)); - + /** \brief destroys metafile area handle \param ma metafile area handle */ diff --git a/bfile/tstmfile1.c b/bfile/tstmfile1.c index 1bd394e..dffc57f 100644 --- a/bfile/tstmfile1.c +++ b/bfile/tstmfile1.c @@ -1,4 +1,4 @@ -/* $Id: tstmfile1.c,v 1.1 2006-11-14 12:41:19 adam Exp $ +/* $Id: tstmfile1.c,v 1.2 2006-12-03 16:05:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void tst1(void) { - MFile_area a = mf_init("main", 0 /* spec */, 0 /* base */); + MFile_area a = mf_init("main", 0 /* spec */, 0 /* base */, 0 /* only sh */); YAZ_CHECK(a); mf_destroy(a); } @@ -40,7 +40,7 @@ void tst1(void) void tst2(void) { char buf[BLOCK_SIZE]; - MFile_area a = mf_init("main", 0 /* spec */, 0 /* base */); + MFile_area a = mf_init("main", 0 /* spec */, 0 /* base */, 0 /* only sh */); MFile f; YAZ_CHECK(a);