Fixed bugs about cppcheck error
This commit is contained in:
@ -960,7 +960,15 @@ bool FdEntity::SetGId(gid_t gid)
|
||||
{
|
||||
orgmeta["x-amz-meta-gid"] = str(gid);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FdEntity::SetContentType(const char* path)
|
||||
{
|
||||
if(!path){
|
||||
return false;
|
||||
}
|
||||
orgmeta["Content-Type"] = S3fsCurl::LookupMimeType(string(path));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FdEntity::SetAllStatus(bool is_loaded)
|
||||
@ -1902,13 +1910,15 @@ bool FdManager::ChangeEntityToTempPath(FdEntity* ent, const char* path)
|
||||
{
|
||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||
|
||||
for(fdent_map_t::iterator iter = fent.begin(); iter != fent.end(); ++iter){
|
||||
for(fdent_map_t::iterator iter = fent.begin(); iter != fent.end(); ){
|
||||
if((*iter).second == ent){
|
||||
fent.erase(iter);
|
||||
fent.erase(iter++);
|
||||
|
||||
string tmppath("");
|
||||
FdManager::MakeRandomTempPath(path, tmppath);
|
||||
fent[tmppath] = ent;
|
||||
}else{
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -132,7 +132,7 @@ class FdEntity
|
||||
|
||||
void Clear(void);
|
||||
bool SetAllStatus(bool is_loaded); // [NOTE] not locking
|
||||
bool SetAllStatusLoaded(void) { return SetAllStatus(true); }
|
||||
//bool SetAllStatusLoaded(void) { return SetAllStatus(true); }
|
||||
bool SetAllStatusUnloaded(void) { return SetAllStatus(false); }
|
||||
|
||||
public:
|
||||
@ -156,6 +156,7 @@ class FdEntity
|
||||
bool SetMode(mode_t mode);
|
||||
bool SetUId(uid_t uid);
|
||||
bool SetGId(gid_t gid);
|
||||
bool SetContentType(const char* path);
|
||||
|
||||
int Load(off_t start = 0, size_t size = 0); // size=0 means loading to end
|
||||
int NoCacheLoadAndPost(off_t start = 0, size_t size = 0); // size=0 means loading to end
|
||||
@ -206,7 +207,7 @@ class FdManager
|
||||
|
||||
static size_t GetEnsureFreeDiskSpace(void) { return FdManager::free_disk_space; }
|
||||
static size_t SetEnsureFreeDiskSpace(size_t size);
|
||||
static size_t InitEnsureFreeDiskSpace(void) { return FdManager::SetEnsureFreeDiskSpace(0); }
|
||||
static size_t InitEnsureFreeDiskSpace(void) { return SetEnsureFreeDiskSpace(0); }
|
||||
static bool IsSafeDiskSpace(const char* path, size_t size);
|
||||
|
||||
FdEntity* GetFdEntity(const char* path, int existfd = -1);
|
||||
|
||||
17
src/s3fs.cpp
17
src/s3fs.cpp
@ -1193,8 +1193,7 @@ static int rename_object(const char* from, const char* to)
|
||||
|
||||
static int rename_object_nocopy(const char* from, const char* to)
|
||||
{
|
||||
int result;
|
||||
headers_t meta;
|
||||
int result;
|
||||
|
||||
S3FS_PRN_INFO1("[from=%s][to=%s]", from , to);
|
||||
|
||||
@ -1207,14 +1206,6 @@ static int rename_object_nocopy(const char* from, const char* to)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Get attributes
|
||||
if(0 != (result = get_object_attribute(from, NULL, &meta))){
|
||||
return result;
|
||||
}
|
||||
|
||||
// Set header
|
||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(string(to));
|
||||
|
||||
// open & load
|
||||
FdEntity* ent;
|
||||
if(NULL == (ent = get_local_fent(from, true))){
|
||||
@ -1222,6 +1213,12 @@ static int rename_object_nocopy(const char* from, const char* to)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
// Set header
|
||||
if(!ent->SetContentType(to)){
|
||||
S3FS_PRN_ERR("could not set content-type for %s", to);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
// upload
|
||||
if(0 != (result = ent->RowFlush(to, true))){
|
||||
S3FS_PRN_ERR("could not upload file(%s): result=%d", to, result);
|
||||
|
||||
Reference in New Issue
Block a user