Skip to content

Commit

Permalink
buaazp: 1.check file existed fixed for buaazp#64 2.added error info l…
Browse files Browse the repository at this point in the history
…og for buaazp#57
  • Loading branch information
buaazp committed Feb 2, 2015
1 parent b886e12 commit c690749
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ int save_img_ssdb(redisContext* c, const char *cache_key, const char *buff, cons
LOG_PRINT(LOG_DEBUG, "Execut ssdb command failure");
return -1;
}
if( !(r->type == REDIS_REPLY_STATUS && strcasecmp(r->str,"OK")==0))
if( !(r->type == REDIS_REPLY_STATUS && strcasecmp(r->str,"OK") == 0))
{
LOG_PRINT(LOG_DEBUG, "Failed to execute save [%s] to ssdb.", cache_key);
LOG_PRINT(LOG_DEBUG, "Failed to execute save [%s] to ssdb: %s", cache_key, r->str);
freeReplyObject(r);
return -1;
}
Expand Down
23 changes: 14 additions & 9 deletions src/zimg.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,25 @@ int save_img(thr_arg_t *thr_arg, const char *buff, const int len, char *md5)
snprintf(save_path, 512, "%s/%d/%d/%s", settings.img_path, lvl1, lvl2, md5sum);
LOG_PRINT(LOG_DEBUG, "save_path: %s", save_path);

if(is_dir(save_path) == 1)
if(is_dir(save_path) != 1)
{
LOG_PRINT(LOG_DEBUG, "Check File Exist. Needn't Save.");
goto cache;
if(mk_dirs(save_path) == -1)
{
LOG_PRINT(LOG_DEBUG, "save_path[%s] Create Failed!", save_path);
goto done;
}
LOG_PRINT(LOG_DEBUG, "save_path[%s] Create Finish.", save_path);
}

if(mk_dirs(save_path) == -1)
{
LOG_PRINT(LOG_DEBUG, "save_path[%s] Create Failed!", save_path);
goto done;
}
LOG_PRINT(LOG_DEBUG, "save_path[%s] Create Finish.", save_path);
snprintf(save_name, 512, "%s/0*0", save_path);
LOG_PRINT(LOG_DEBUG, "save_name-->: %s", save_name);

if(is_file(save_name) == 1)
{
LOG_PRINT(LOG_DEBUG, "Check File Exist. Needn't Save.");
goto cache;
}

if(new_img(buff, len, save_name) == -1)
{
LOG_PRINT(LOG_DEBUG, "Save Image[%s] Failed!", save_name);
Expand Down
2 changes: 0 additions & 2 deletions src/zutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ int is_file(const char *filename)
return -1;
}



/**
* @brief is_img Check a file is a image we support(jpg, png, gif).
*
Expand Down

0 comments on commit c690749

Please sign in to comment.