fix empty epg.db if regeneration coincides with raw EPG update
This commit is contained in:
parent
abe92a3135
commit
000c750b19
6
epg.c
6
epg.c
|
@ -178,7 +178,7 @@ check_filter(struct epgfilter *f, enum epgfiltertype type,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
parse(char *epgpath,
|
parse(char *epgpath,
|
||||||
void (*callback)(struct epg *, struct section *, struct data *,
|
void (*callback)(struct epg *, struct section *, struct data *,
|
||||||
struct descriptor **, void *), void *val, struct epgfilter *filter)
|
struct descriptor **, void *), void *val, struct epgfilter *filter)
|
||||||
|
@ -188,7 +188,7 @@ parse(char *epgpath,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!(epg = open_file(epgpath)))
|
if (!(epg = open_file(epgpath)))
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
while (epg->offset < epg->binsize)
|
while (epg->offset < epg->binsize)
|
||||||
{
|
{
|
||||||
|
@ -439,6 +439,8 @@ parse(char *epgpath,
|
||||||
}
|
}
|
||||||
|
|
||||||
close_file(epg);
|
close_file(epg);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
2
lint.h
2
lint.h
|
@ -36,7 +36,7 @@ void dump_section(struct section *);
|
||||||
struct data *read_data(struct epg *);
|
struct data *read_data(struct epg *);
|
||||||
void dump_data(struct data *);
|
void dump_data(struct data *);
|
||||||
|
|
||||||
void parse(char *,
|
int parse(char *,
|
||||||
void (*)(struct epg *, struct section *, struct data *,
|
void (*)(struct epg *, struct section *, struct data *,
|
||||||
struct descriptor **, void *), void *, struct epgfilter *);
|
struct descriptor **, void *), void *, struct epgfilter *);
|
||||||
|
|
||||||
|
|
26
main.c
26
main.c
|
@ -21,7 +21,7 @@
|
||||||
#include "lint.h"
|
#include "lint.h"
|
||||||
|
|
||||||
int debug = 0;
|
int debug = 0;
|
||||||
const char *version = "1.2.6";
|
const char *version = "1.2.7";
|
||||||
unsigned long sysopts = 0;
|
unsigned long sysopts = 0;
|
||||||
unsigned long filterflags = 0;
|
unsigned long filterflags = 0;
|
||||||
static time_t latest_stamp = 0;
|
static time_t latest_stamp = 0;
|
||||||
|
@ -236,7 +236,7 @@ json_escape_len(unsigned int len, char *txt)
|
||||||
exit(0); \
|
exit(0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
void
|
static void
|
||||||
sqlitedumpstart(char *file)
|
sqlitedumpstart(char *file)
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN + 1];
|
char buf[MAXPATHLEN + 1];
|
||||||
|
@ -282,8 +282,8 @@ sqlitedumpstart(char *file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
sqlitedumpend(char *file)
|
sqlitedumpend(char *file, int commit)
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN + 1];
|
char buf[MAXPATHLEN + 1];
|
||||||
char *error;
|
char *error;
|
||||||
|
@ -293,8 +293,10 @@ sqlitedumpend(char *file)
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
|
|
||||||
sprintf(buf, "%s.load", file);
|
sprintf(buf, "%s.load", file);
|
||||||
/*unlink(file);*/
|
if (commit)
|
||||||
rename(buf, file);
|
rename(buf, file);
|
||||||
|
else
|
||||||
|
unlink(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1050,9 +1052,11 @@ nextopt:
|
||||||
#ifdef HAVE_SQLITE3
|
#ifdef HAVE_SQLITE3
|
||||||
else if (!strcmp(argv[0], "sqlitedump") && argc == 2)
|
else if (!strcmp(argv[0], "sqlitedump") && argc == 2)
|
||||||
{
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
sqlitedumpstart(argv[1]);
|
sqlitedumpstart(argv[1]);
|
||||||
parse(epgpath, sqlitedump, NULL, filter);
|
r = parse(epgpath, sqlitedump, NULL, filter);
|
||||||
sqlitedumpend(argv[1]);
|
sqlitedumpend(argv[1], r);
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "sqlitedumpd") && argc == 2)
|
else if (!strcmp(argv[0], "sqlitedumpd") && argc == 2)
|
||||||
{
|
{
|
||||||
|
@ -1070,11 +1074,13 @@ nextopt:
|
||||||
if (st.st_mtime > last)
|
if (st.st_mtime > last)
|
||||||
{
|
{
|
||||||
time_t tm = time(NULL);
|
time_t tm = time(NULL);
|
||||||
|
int r;
|
||||||
|
|
||||||
printf("epgd: Regenerating.\n");
|
printf("epgd: Regenerating.\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
sqlitedumpstart(argv[1]);
|
sqlitedumpstart(argv[1]);
|
||||||
parse(epgpath, sqlitedump, NULL, filter);
|
r = parse(epgpath, sqlitedump, NULL, filter);
|
||||||
sqlitedumpend(argv[1]);
|
sqlitedumpend(argv[1], r);
|
||||||
printf("epgd: Done in %ld seconds.\n",
|
printf("epgd: Done in %ld seconds.\n",
|
||||||
time(NULL) - tm);
|
time(NULL) - tm);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
Loading…
Reference in New Issue