modified cache_create
This commit is contained in:
parent
212e319f20
commit
07b8382022
13
src/cache.c
13
src/cache.c
|
@ -139,7 +139,7 @@ static Cache **CACHE_OPENED;
|
|||
/**
|
||||
* \brief The number of opened cache files
|
||||
*/
|
||||
static int N_CACHE_OPENED;
|
||||
static int N_CACHE_OPENED = 0;
|
||||
|
||||
void CacheSystem_init(const char *path)
|
||||
{
|
||||
|
@ -512,7 +512,7 @@ static int Cache_exist(const char *fn)
|
|||
return !(meta_exists & data_exists);
|
||||
}
|
||||
|
||||
Cache *Cache_create(const char *fn, long len, long time)
|
||||
int Cache_create(const char *fn, long len, long time)
|
||||
{
|
||||
Cache *cf = Cache_alloc();
|
||||
|
||||
|
@ -521,17 +521,16 @@ Cache *Cache_create(const char *fn, long len, long time)
|
|||
cf->content_length = len;
|
||||
|
||||
if (Data_create(cf)) {
|
||||
Cache_free(cf);
|
||||
fprintf(stderr, "Cache_create(): Data_create() failed!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Meta_create(cf)) {
|
||||
Cache_free(cf);
|
||||
fprintf(stderr, "Cache_create(): Meta_create() failed!\n");
|
||||
return NULL;
|
||||
}
|
||||
return cf;
|
||||
|
||||
Cache_free(cf);
|
||||
|
||||
return Cache_exist(fn);
|
||||
}
|
||||
|
||||
static void Cache_delete(const char *fn)
|
||||
|
|
20
src/cache.h
20
src/cache.h
|
@ -52,17 +52,14 @@ typedef struct {
|
|||
*/
|
||||
void CacheSystem_init(const char *dir);
|
||||
|
||||
/**
|
||||
* \brief open a cache file set
|
||||
* \note Call this when FUSE opens a file
|
||||
*/
|
||||
Cache *Cache_open(const char *fn);
|
||||
|
||||
/**
|
||||
* \brief create a cache file set
|
||||
* * \return
|
||||
* - 0, if the cache file was created succesfully
|
||||
* - -1, otherwise
|
||||
* \note Call this when creating a new LinkTable
|
||||
*/
|
||||
Cache *Cache_create(const char *fn, long len, long time);
|
||||
int Cache_create(const char *fn, long len, long time);
|
||||
|
||||
/**
|
||||
* \brief Create directories under the cache directory structure, if they do
|
||||
|
@ -75,6 +72,13 @@ Cache *Cache_create(const char *fn, long len, long time);
|
|||
*/
|
||||
int CacheDir_create(const char *fn);
|
||||
|
||||
/***************************** Work in Progress ******************************/
|
||||
/**
|
||||
* \brief open a cache file set
|
||||
* \note Call this when FUSE opens a file
|
||||
*/
|
||||
Cache *Cache_open(const char *fn);
|
||||
|
||||
/**
|
||||
* \brief Check if a segment exists.
|
||||
* \note Call this when deciding whether to download a file
|
||||
|
@ -89,8 +93,6 @@ int Seg_exist(Cache *cf, long start);
|
|||
*/
|
||||
void Seg_set(Cache *cf, long start, int i);
|
||||
|
||||
|
||||
|
||||
/***************************** To be completed ******************************/
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue