Merge pull request #352 from ggtakec/master

Remove stat file cache dir if specified del_cache - #337
This commit is contained in:
Takeshi Nakatani 2016-02-07 04:05:45 +09:00
commit 938554e569
3 changed files with 26 additions and 6 deletions

View File

@ -124,6 +124,23 @@ bool CacheFileStat::DeleteCacheFileStat(const char* path)
return true; return true;
} }
// [NOTE]
// If remove stat file directory, it should do before removing
// file cache directory.
//
bool CacheFileStat::DeleteCacheFileStatDirectory(void)
{
string top_path = FdManager::GetCacheDir();
if(top_path.empty() || bucket.empty()){
return true;
}
top_path += "/.";
top_path += bucket;
top_path += ".stat";
return delete_files_in_dir(top_path.c_str(), true);
}
//------------------------------------------------ //------------------------------------------------
// CacheFileStat methods // CacheFileStat methods
//------------------------------------------------ //------------------------------------------------

View File

@ -38,6 +38,7 @@ class CacheFileStat
public: public:
static bool DeleteCacheFileStat(const char* path); static bool DeleteCacheFileStat(const char* path);
static bool CheckCacheFileStatTopDir(void); static bool CheckCacheFileStatTopDir(void);
static bool DeleteCacheFileStatDirectory(void);
explicit CacheFileStat(const char* tpath = NULL); explicit CacheFileStat(const char* tpath = NULL);
~CacheFileStat(); ~CacheFileStat();

View File

@ -3315,6 +3315,11 @@ static void* s3fs_init(struct fuse_conn_info* conn)
{ {
S3FS_PRN_CRIT("init v%s(commit:%s) with %s", VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name()); S3FS_PRN_CRIT("init v%s(commit:%s) with %s", VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name());
// cache(remove cache dirs at first)
if(is_remove_cache && (!CacheFileStat::DeleteCacheFileStatDirectory() || !FdManager::DeleteCacheDirectory())){
S3FS_PRN_DBG("Could not inilialize cache directory.");
}
// ssl init // ssl init
if(!s3fs_init_global_ssl()){ if(!s3fs_init_global_ssl()){
S3FS_PRN_CRIT("could not initialize for ssl libraries."); S3FS_PRN_CRIT("could not initialize for ssl libraries.");
@ -3350,10 +3355,7 @@ static void* s3fs_init(struct fuse_conn_info* conn)
conn->want |= FUSE_CAP_ATOMIC_O_TRUNC; conn->want |= FUSE_CAP_ATOMIC_O_TRUNC;
} }
#endif #endif
// cache
if(is_remove_cache && !FdManager::DeleteCacheDirectory()){
S3FS_PRN_DBG("Could not inilialize cache directory.");
}
return NULL; return NULL;
} }
@ -3365,8 +3367,8 @@ static void s3fs_destroy(void*)
if(!S3fsCurl::DestroyS3fsCurl()){ if(!S3fsCurl::DestroyS3fsCurl()){
S3FS_PRN_WARN("Could not release curl library."); S3FS_PRN_WARN("Could not release curl library.");
} }
// cache // cache(remove at last)
if(is_remove_cache && !FdManager::DeleteCacheDirectory()){ if(is_remove_cache && (!CacheFileStat::DeleteCacheFileStatDirectory() || !FdManager::DeleteCacheDirectory())){
S3FS_PRN_WARN("Could not remove cache directory."); S3FS_PRN_WARN("Could not remove cache directory.");
} }
// ssl // ssl