projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Document type=adelete for dom
[idzebra-moved-to-github.git]
/
index
/
update_file.c
diff --git
a/index/update_file.c
b/index/update_file.c
index
5a50d04
..
400fb93
100644
(file)
--- a/
index/update_file.c
+++ b/
index/update_file.c
@@
-1,8
+1,5
@@
-/* $Id: update_file.c,v 1.6 2007-10-29 09:25:41 adam Exp $
- Copyright (C) 1995-2007
- Index Data ApS
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+ Copyright (C) 2004-2013 Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
@@
-20,6
+17,9
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <assert.h>
#include <sys/types.h>
#include <stdio.h>
#include <assert.h>
#include <sys/types.h>
@@
-49,7
+49,7
@@
static void dump_file_dict(Dict dict)
int before = 10;
int after = 1000;
char term[1000];
int before = 10;
int after = 1000;
char term[1000];
-
+
strcpy(term, "0");
dict_scan(dict, term, &before, &after, 0, dump_file_dict_func);
}
strcpy(term, "0");
dict_scan(dict, term, &before, &after, 0, dump_file_dict_func);
}
@@
-75,10
+75,9
@@
static void fileDelete_r(ZebraHandle zh,
{
case dirs_file:
sprintf(tmppath, "%s%s", base, dst->path);
{
case dirs_file:
sprintf(tmppath, "%s%s", base, dst->path);
- zebra_extract_file(zh, &dst->sysno, tmppath, 1);
-
+ zebra_extract_file(zh, &dst->sysno, tmppath, action_delete);
strcpy(tmppath, dst->path);
strcpy(tmppath, dst->path);
- dst = dirs_read(di);
+ dst = dirs_read(di);
dirs_del(di, tmppath);
break;
case dirs_dir:
dirs_del(di, tmppath);
break;
case dirs_dir:
@@
-94,7
+93,7
@@
static void fileDelete_r(ZebraHandle zh,
static void file_update_r(ZebraHandle zh,
struct dirs_info *di, struct dirs_entry *dst,
static void file_update_r(ZebraHandle zh,
struct dirs_info *di, struct dirs_entry *dst,
- const char *base, char *src,
+ const char *base, char *src,
int level)
{
struct dir_entry *e_src;
int level)
{
struct dir_entry *e_src;
@@
-137,7
+136,7
@@
static void file_update_r(ZebraHandle zh,
src[src_len] = '/';
src[++src_len] = '\0';
}
src[src_len] = '/';
src[++src_len] = '\0';
}
- dst = dirs_read(di);
+ dst = dirs_read(di);
}
dir_sort(e_src);
}
dir_sort(e_src);
@@
-166,13
+165,13
@@
static void file_update_r(ZebraHandle zh,
{
strcpy(src + src_len, e_src[i_src].name);
sprintf(tmppath, "%s%s", base, src);
{
strcpy(src + src_len, e_src[i_src].name);
sprintf(tmppath, "%s%s", base, src);
-
+
switch(e_src[i_src].kind)
{
case dirs_file:
if (e_src[i_src].mtime > dst->mtime)
{
switch(e_src[i_src].kind)
{
case dirs_file:
if (e_src[i_src].mtime > dst->mtime)
{
- if (zebra_extract_file(zh, &dst->sysno, tmppath, 0) == ZEBRA_OK)
+ if (zebra_extract_file(zh, &dst->sysno, tmppath, action_update) == ZEBRA_OK)
{
dirs_add(di, src, dst->sysno, e_src[i_src].mtime);
}
{
dirs_add(di, src, dst->sysno, e_src[i_src].mtime);
}
@@
-187,7
+186,7
@@
static void file_update_r(ZebraHandle zh,
yaz_log(YLOG_DEBUG, "last is %s", dst ? dst->path : "null");
break;
default:
yaz_log(YLOG_DEBUG, "last is %s", dst ? dst->path : "null");
break;
default:
- dst = dirs_read(di);
+ dst = dirs_read(di);
}
i_src++;
}
}
i_src++;
}
@@
-200,8
+199,8
@@
static void file_update_r(ZebraHandle zh,
switch (e_src[i_src].kind)
{
case dirs_file:
switch (e_src[i_src].kind)
{
case dirs_file:
- if (zebra_extract_file(zh, &sysno, tmppath, 0) == ZEBRA_OK)
- dirs_add(di, src, sysno, e_src[i_src].mtime);
+ if (zebra_extract_file(zh, &sysno, tmppath, action_update) == ZEBRA_OK)
+ dirs_add(di, src, sysno, e_src[i_src].mtime);
break;
case dirs_dir:
file_update_r(zh, di, dst, base, src, level+1);
break;
case dirs_dir:
file_update_r(zh, di, dst, base, src, level+1);
@@
-219,7
+218,7
@@
static void file_update_r(ZebraHandle zh,
switch (dst->kind)
{
case dirs_file:
switch (dst->kind)
{
case dirs_file:
- zebra_extract_file(zh, &dst->sysno, tmppath, 1);
+ zebra_extract_file(zh, &dst->sysno, tmppath, action_delete);
dirs_del(di, dst->path);
dst = dirs_read(di);
break;
dirs_del(di, dst->path);
dst = dirs_read(di);
break;
@@
-258,7
+257,7
@@
static void file_update_top(ZebraHandle zh, Dict dict, const char *path)
if (ret == -1)
{
yaz_log(YLOG_WARN|YLOG_ERRNO, "Cannot access path %s", src);
if (ret == -1)
{
yaz_log(YLOG_WARN|YLOG_ERRNO, "Cannot access path %s", src);
- }
+ }
else if (S_ISREG(sbuf.st_mode))
{
struct dirs_entry *e_dst;
else if (S_ISREG(sbuf.st_mode))
{
struct dirs_entry *e_dst;
@@
-268,13
+267,13
@@
static void file_update_top(ZebraHandle zh, Dict dict, const char *path)
if (e_dst)
{
if (sbuf.st_mtime > e_dst->mtime)
if (e_dst)
{
if (sbuf.st_mtime > e_dst->mtime)
- if (zebra_extract_file(zh, &e_dst->sysno, src, 0) == ZEBRA_OK)
+ if (zebra_extract_file(zh, &e_dst->sysno, src, action_update) == ZEBRA_OK)
dirs_add(di, src, e_dst->sysno, sbuf.st_mtime);
}
else
{
zint sysno = 0;
dirs_add(di, src, e_dst->sysno, sbuf.st_mtime);
}
else
{
zint sysno = 0;
- if (zebra_extract_file(zh, &sysno, src, 0) == ZEBRA_OK)
+ if (zebra_extract_file(zh, &sysno, src, action_update) == ZEBRA_OK)
dirs_add(di, src, sysno, sbuf.st_mtime);
}
dirs_free(&di);
dirs_add(di, src, sysno, sbuf.st_mtime);
}
dirs_free(&di);
@@
-316,7
+315,7
@@
static ZEBRA_RES zebra_open_fmatch(ZebraHandle zh, Dict *dictp)
ZEBRA_RES zebra_remove_file_match(ZebraHandle zh)
{
Dict dict;
ZEBRA_RES zebra_remove_file_match(ZebraHandle zh)
{
Dict dict;
-
+
if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK)
return ZEBRA_FAIL;
if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK)
return ZEBRA_FAIL;
@@
-337,7
+336,7
@@
ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path)
}
if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK)
return ZEBRA_FAIL;
}
if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK)
return ZEBRA_FAIL;
-
+
if (!strcmp(path, "") || !strcmp(path, "-"))
{
char src[1024];
if (!strcmp(path, "") || !strcmp(path, "-"))
{
char src[1024];
@@
-357,6
+356,7
@@
ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path)
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab