Skip to content

Commit

Permalink
pr review #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ken90242 committed Aug 8, 2023
1 parent d058e72 commit d7edd91
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
26 changes: 17 additions & 9 deletions curvefs/src/client/warmup/warmup_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,35 @@ using curvefs::client::common::WarmupStorageType;
class WarmupFile {
public:
explicit WarmupFile(fuse_ino_t key = 0,
uint64_t fileLen = 0,
const std::string& mountPoint = "",
const std::string& root = "")
: key_(key), fileLen_(fileLen), mountPoint_(mountPoint), root_(root) {}
uint64_t fileLen = 0)
: key_(key), fileLen_(fileLen) {}

fuse_ino_t GetKey() const { return key_; }
uint64_t GetFileLen() const { return fileLen_; }
std::string GetMountPoint() const { return mountPoint_; }
std::string GetRoot() const { return root_; }
bool operator==(const WarmupFile &other) const {
return key_ == other.key_;
}

private:
fuse_ino_t key_;
uint64_t fileLen_;
std::string mountPoint_;
std::string root_;
};

using WarmupFilelist = WarmupFile;
class WarmupFilelist : public WarmupFile {
public:
explicit WarmupFilelist(fuse_ino_t key = 0,
uint64_t fileLen = 0,
const std::string& mountPoint = "",
const std::string& root = "")
: WarmupFile(key, fileLen), mountPoint_(mountPoint), root_(root) {}

std::string GetMountPoint() const { return mountPoint_; }
std::string GetRoot() const { return root_; }

private:
std::string mountPoint_;
std::string root_;
}

class WarmupInodes {
public:
Expand Down
3 changes: 3 additions & 0 deletions tools-v2/internal/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ var (
ErrBsGetAllSnapshotResult = func() *CmdError {
return NewInternalCmdError(72, "get all snapshot results fail, err: %s")
}
ErrVerifyError = func() *CmdError {
return NewInternalCmdError(73, "verify fail, err: %s")
}

// http error
ErrHttpUnreadableResult = func() *CmdError {
Expand Down
12 changes: 6 additions & 6 deletions tools-v2/pkg/cli/command/curvefs/warmup/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ func (aCmd *AddCommand) verifyFilelist() *cmderror.CmdError {
for _, line := range lines {
rel, err := filepath.Rel(aCmd.Mountpoint.MountPoint, line)
if err != nil || strings.HasPrefix(rel, "..") {
convertFailMsg := fmt.Sprintf("[%s:%s] is not saved in curvefs", aCmd.Path, line)
convertErr := cmderror.ErrConverResult()
convertErr.Format(convertFailMsg, err.Error())
verifyFailMsg := fmt.Sprintf("[%s:%s] is not saved in curvefs", aCmd.Path, line)
verifyErr := cmderror.ErrVerifyError()
verifyErr.Format(verifyFailMsg, err.Error())
break
}
}
Expand All @@ -187,9 +187,9 @@ func (aCmd *AddCommand) verifyFilelist() *cmderror.CmdError {
func (aCmd *AddCommand) RunCommand(cmd *cobra.Command, args []string) error {
xattr := CURVEFS_WARMUP_OP_ADD_SINGLE
if !aCmd.Single {
convertErr := aCmd.verifyFilelist()
if convertErr.TypeCode() != cmderror.CODE_SUCCESS {
return convertErr.ToError()
verifyErr := aCmd.verifyFilelist()
if verifyErr.TypeCode() != cmderror.CODE_SUCCESS {
return verifyErr.ToError()
}
xattr = CURVEFS_WARMUP_OP_ADD_LIST
}
Expand Down

0 comments on commit d7edd91

Please sign in to comment.