mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 09:18:55 +00:00
Merge pull request #1333 from ggtakec/similar_processing
Put similar processing together into method GetCacheFileStatTopDir
This commit is contained in:
commit
e0a38adaf6
@ -65,13 +65,28 @@ static const int MAX_MULTIPART_CNT = 10 * 1000; // S3 multipart max count
|
|||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// CacheFileStat class methods
|
// CacheFileStat class methods
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
|
string CacheFileStat::GetCacheFileStatTopDir()
|
||||||
|
{
|
||||||
|
string top_path("");
|
||||||
|
if(!FdManager::IsCacheDir() || bucket.empty()){
|
||||||
|
return top_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stat top dir( "/<cache_dir>/.<bucket_name>.stat" )
|
||||||
|
top_path += FdManager::GetCacheDir();
|
||||||
|
top_path += "/.";
|
||||||
|
top_path += bucket;
|
||||||
|
top_path += ".stat";
|
||||||
|
return top_path;
|
||||||
|
}
|
||||||
|
|
||||||
bool CacheFileStat::MakeCacheFileStatPath(const char* path, string& sfile_path, bool is_create_dir)
|
bool CacheFileStat::MakeCacheFileStatPath(const char* path, string& sfile_path, bool is_create_dir)
|
||||||
{
|
{
|
||||||
// make stat dir top path( "/<cache_dir>/.<bucket_name>.stat" )
|
string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||||
string top_path = FdManager::GetCacheDir();
|
if(top_path.empty()){
|
||||||
top_path += "/.";
|
S3FS_PRN_ERR("The path to cache top dir is empty.");
|
||||||
top_path += bucket;
|
return false;
|
||||||
top_path += ".stat";
|
}
|
||||||
|
|
||||||
if(is_create_dir){
|
if(is_create_dir){
|
||||||
int result;
|
int result;
|
||||||
@ -90,14 +105,11 @@ bool CacheFileStat::MakeCacheFileStatPath(const char* path, string& sfile_path,
|
|||||||
|
|
||||||
bool CacheFileStat::CheckCacheFileStatTopDir()
|
bool CacheFileStat::CheckCacheFileStatTopDir()
|
||||||
{
|
{
|
||||||
if(!FdManager::IsCacheDir()){
|
string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||||
|
if(top_path.empty()){
|
||||||
|
S3FS_PRN_INFO("The path to cache top dir is empty, thus not need to check permission.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// make stat dir top path( "/<cache_dir>/.<bucket_name>.stat" )
|
|
||||||
string top_path = FdManager::GetCacheDir();
|
|
||||||
top_path += "/.";
|
|
||||||
top_path += bucket;
|
|
||||||
top_path += ".stat";
|
|
||||||
|
|
||||||
return check_exist_dir_permission(top_path.c_str());
|
return check_exist_dir_permission(top_path.c_str());
|
||||||
}
|
}
|
||||||
@ -130,14 +142,11 @@ bool CacheFileStat::DeleteCacheFileStat(const char* path)
|
|||||||
//
|
//
|
||||||
bool CacheFileStat::DeleteCacheFileStatDirectory()
|
bool CacheFileStat::DeleteCacheFileStatDirectory()
|
||||||
{
|
{
|
||||||
string top_path = FdManager::GetCacheDir();
|
string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||||
|
if(top_path.empty()){
|
||||||
if(top_path.empty() || bucket.empty()){
|
S3FS_PRN_INFO("The path to cache top dir is empty, thus not need to remove it.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
top_path += "/.";
|
|
||||||
top_path += bucket;
|
|
||||||
top_path += ".stat";
|
|
||||||
return delete_files_in_dir(top_path.c_str(), true);
|
return delete_files_in_dir(top_path.c_str(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class CacheFileStat
|
|||||||
static bool MakeCacheFileStatPath(const char* path, std::string& sfile_path, bool is_create_dir = true);
|
static bool MakeCacheFileStatPath(const char* path, std::string& sfile_path, bool is_create_dir = true);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static std::string GetCacheFileStatTopDir(void);
|
||||||
static bool DeleteCacheFileStat(const char* path);
|
static bool DeleteCacheFileStat(const char* path);
|
||||||
static bool CheckCacheFileStatTopDir(void);
|
static bool CheckCacheFileStatTopDir(void);
|
||||||
static bool DeleteCacheFileStatDirectory(void);
|
static bool DeleteCacheFileStatDirectory(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user