Skip to content
Permalink
Browse files

working on issue #59 to remove outdated files

  • Loading branch information...
jankammerath committed Dec 24, 2017
1 parent cc4f11a commit 7d0b42acc5da111e61cab6f1fc32f5ed4620bbd0
Showing with 34 additions and 2 deletions.
  1. BIN bin/iptvx
  2. +1 −1 cfg/iptvx.conf
  3. +1 −1 debian.rules
  4. +32 −0 src/epg.c
BIN +1.13 KB (100%) bin/iptvx
Binary file not shown.
@@ -30,4 +30,4 @@ epg_hours = 72
stream_log_output = false

# include channels
@include "/home/jan/Development/iptvx/cfg/channels.conf"
@include "/etc/iptvx/channels.conf"
@@ -37,7 +37,7 @@ install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# dh_installdirs

# Add here commands to install the package
# The DESTDIR Has To Be Exactly /usr/src/packages/BUILD/debian/<nameOfPackage>
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dirent.h>
#include <glib.h>
#include <libconfig.h>
#include <SDL/SDL.h>
@@ -96,6 +97,34 @@ void iptvx_epg_set_storage_hours(int hours){
iptvx_epg_storage_hours = hours;
}

/*
Cleans local files when they are outdated
*/
void iptvx_epg_clean_files(){
DIR *d;
struct dirent *dir;
char* epgCacheDir = g_strjoin("/",epg_data_dir->str,"epg",NULL);
d = opendir(epgCacheDir);
if(d){
while ((dir = readdir(d)) != NULL){
/* make sure its not . or .. as filename */
if(g_strcmp0(dir->d_name,".") != 0 && g_strcmp0(dir->d_name,"..") != 0){
char* epgFileName = g_strjoin("/",epgCacheDir,dir->d_name,NULL);

struct stat attrib;
stat(epgFileName, &attrib);
char modified_date[10];
strftime(modified_date, 10, "%d-%m-%y", gmtime(&(attrib.st_ctime)));

double fileAge = difftime(time(NULL),attrib.st_ctime);

// printf("Epg file '%s': %f\n", dir->d_name,fileAge);
}
}
closedir(d);
}
}

/*
Returns all channel and epg info as JSON string
@return JSON string with all EPG info
@@ -557,6 +586,9 @@ void iptvx_epg_load_channel(channel* current, time_t epg_time, bool overwrite_ca
initiates the epg load for each channel
*/
int iptvx_epg_load(void* nothing){
/* delete any trash that might still be on disk */
iptvx_epg_clean_files();

int c = 0;
for(c = 0; c < list->len; c++){
/* get this channel */

0 comments on commit 7d0b42a

Please sign in to comment.
You can’t perform that action at this time.